Bob is sitting through another session of physics class, with a topic regarding the force of gravity on an object. Bob thinks that the force of gravity is the same for all objects, regardless of their mass. However, his teacher Dr. Henri knows better. To convince Bob that he is wrong, Dr. Henri dug up
Dr. Henri knows that the scales will tip to the plate holding a higher mass, or remain balanced if the masses on both sides are equal. To be as convincing as possible, Dr. Henri would like to arrange the
Constraints
Subtask 1 [20%]
Subtask 2 [30%]
Subtask 3 [50%]
No additional constraints.
Input Specification
The first line contains an integer
The second line contains
Output Specification
On the first line output an integer
On the
Each weight must be placed on a plate, and one plate may only hold one weight. The number of tipped scales in your arrangement must be exactly
Sample Input
3
1 2 1 2 1 1
Sample Output
2
1 4
2 3
6 5
Explanation
The first scale will tip to the right, and the second scale will tip to the left. The third scale remains balanced. It can be proven that this is the maximum possible number of tipped scales, so this is a valid arrangement of the weights.
Comments
Why is my submission getting rte/tle?
your while loop will never end because i is not changing.
You should try compiling your code on your own computer first before submitting because your code cannot pass the sample
I fixed it but it's still not working. Can I see a solution? I'm a beginner so I have to learn implementation or maybe I am missing some knowledge.
You are leaving out some corner cases try to make some test cases on your own. and there might be other things wrong that I don't see...