Time Limit: 2000MS |
| Memory Limit: 65536KB |
| 64bit IO Format: %lld & %llu |
Description Last week, n students participated in the annual programming contest of Marjar University. Students are labeled from 1 to n. They came to the competition area one by one, one after another in the increasing order of their label. Each of them went in, and before sitting down at his desk, was greeted by his/her friends who were present in the room by shaking hands. For each student, you are given the number of students who he/she shook hands with when he/she came in the area. For each student, you need to find the maximum number of friends he/she could possibly have. For the sake of simplicity, you just need to print the maximum value of the n Input There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case: The first line contains an integer n (1 ≤ n ≤ 100000) -- the number of students. The next line contains n integers a1, a2, ..., an (0 ≤ ai < i), where ai is the number of students who the i-th student shook hands with when he/she came in the area. Output For each test case, output an integer denoting the answer. Sample Input 230 1 150 0 1 1 1 Sample Output 23 //题意: 有n个人按照次序进场,在后面进来的选手会与在他前面进来的朋友握手(不是朋友的就不会握手),问他们中握手最多的有几次? //思路: 因为是求最多的,所以如果他们握手的话就让他们都与第一个握手,这样遍历下去就会是第一个人握手次数最多,但是这还有点不严密,因为如果是这种情况0 0 2 的话应该输出2,所以在遍历时还得取最大值。
|