#P10956. [2015杭电多校]Average
[2015杭电多校]Average
Average
Problem Description
There are soda sitting around a round table. soda are numbered from to and -th soda is adjacent to -th soda, -st soda is adjacent to -th soda. Each soda has some candies in their hand. And they want to make the number of candies the same by doing some taking and giving operations. More specifically, every two adjacent soda and can do one of the following operations only once:
- -th soda gives -th soda a candy if he has one;
- -th soda gives -th soda a candy if he has one;
- they just do nothing. Now you are to determine whether it is possible and give a sequence of operations.
Input
There are multiple test cases. The first line of input contains an integer , indicating the number of test cases. For each test case: The first contains an integer , the number of soda. The next line contains integers , where denotes the candy -th soda has.
Output
For each test case, output "YES" (without the quotes) if possible, otherwise output "NO" (without the quotes) in the first line. If possible, then the output an integer in the second line denoting the number of operations needed. Then each of the following lines contain two integers and , which means that -th soda gives -th soda a candy.
Sample Input
3
6
1 0 1 0 0 0
5
1 1 1 1 1
3
1 2 3
Sample Output
NO
YES
0
YES
2
2 1
3 2
Author
zimpha@zju
Source
2015 Multi-University Training Contest 6