Rectangular Polygon

Special Judge Time Limit: 2000/1000MS (Java/Others) Memory Limit: 512000/256000KB (Java/Others)

Problem Description

      A rectangular polygon is a polygon whose edges are all parallel to the coordinate axes. The polygon must have a single, non-intersecting boundary. No two adjacent sides must be parallel. 

      Johnny has several sticks of various lengths. He would like to construct a rectangular polygon. He is planning to use sticks as horizontal edges of the polygon, and draw vertical edges with a pen. 

      Now Johnny wonders, how many sticks he can use. Help him, find the maximal number of sticks that Johnny can use. He will use sticks only as horizontal edges.

Input

      The first line of the input file contains n — the number of sticks (1 ≤ n ≤ 100). The second line contains n integer numbers — the lengths of the sticks he has. The length of each stick doesn’t exceed 200.

Output

      Print l — the number of sticks Johnny can use at the first line of the output file. The following 2l lines must contain the vertices of the rectangular polygon Johnny can construct. Vertices must be listed in order of traversal. The first two vertices must be the ends of a horizontal edge. If there are several solution, output any one. Vertex coordinates must not exceed 109
.      If no polygon can be constructed, output l = 0.

Sample Input

4
1 2 3 5
4
1 2 4 8
4
1 1 1 1

Sample Output

3
0 0
1 0
1 1
3 1
3 2
0 2
0
4
0 0
1 0
1 1
2 1
2 -2
1 -2
1 -1
0 -1

Hint

单组数据

      In the first example Johnny uses a stick of length 1 for (0, 0)−(1, 0) edge, a stick of length 2 for (1, 1)−(3, 1) edge and a stick of length 3 for (3, 2) − (0, 2) edge. There is no way to use all four sticks.

Source

Andrew Stankevich Contest 23

Manager

Information
Solved Number67
Submit Number154
Problem Tags
dp
No tag edit access
温馨提示:AC后可以编辑标签哦. ^-^
Login
LoginCancel