Handshakes


Time Limit: 2 Seconds      Memory Limit: 65536 KB


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 numbers described in the previous line.

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 a1a2,
..., 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

2
3
0 1 1
5
0 0 1 1 1

Sample Output

2
3

浙大的校赛题,,不能说坑吧只怪自己理解错了,原来a[i]表示与第i个人进来和a[i]个人握手,然后求朋友最多的数量,可我们做的时候大部分把那句话理解为i与第a[i]个人握手,毕竟a[i]的范围太符合了。。这样理解题意后完全是道水题~~

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
const int N=100000+10;
int a[N];
int main()
{
int t,n,i,maxx;
scanf("%d",&t);
while(t--)
{
maxx=0;
scanf("%d",&n);
for(i=1; i<=n; i++)
{
scanf("%d",&a[i]);
if(a[i])
maxx++;
if(a[i]>maxx)
maxx=a[i];
}
printf("%d\n",maxx);
}
return 0;
}

The 16th Zhejiang University Programming Contest-的更多相关文章

  1. zoj 4020 The 18th Zhejiang University Programming Contest Sponsored by TuSimple - G Traffic Light(广搜)

    题目链接:The 18th Zhejiang University Programming Contest Sponsored by TuSimple - G Traffic Light 题解: 题意 ...

  2. The 15th Zhejiang University Programming Contest

    a  ZOJ 3860 求和大家不一样的那个数,签到,map水之 #include<cstdio> #include<map> using namespace std; map ...

  3. ZOJ3865:Superbot(BFS) The 15th Zhejiang University Programming Contest

    一个有几个小坑的bfs 题目很长,但并不复杂,大概总结起来有这么点. 有t组输入 每组输入n, m, p.表示一个n*m的地图,每p秒按键会右移一次(这个等会儿再讲). 然后是地图的输入.其中'@'为 ...

  4. The 19th Zhejiang University Programming Contest - H

    Princess Cjb is caught by Heltion again! Her knights Little Sub and Little Potato are going to Helti ...

  5. The 19th Zhejiang University Programming Contest Sponsored by TuSimple (Mirror) B"Even Number Theory"(找规律???)

    传送门 题意: 给出了三个新定义: E-prime : ∀ num ∈ E,不存在两个偶数a,b,使得 num=a*b;(简言之,num的一对因子不能全为偶数) E-prime factorizati ...

  6. The 19th Zhejiang University Programming Contest Sponsored by TuSimple (Mirror)

    http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=391 A     Thanks, TuSimple! Time ...

  7. 2019 The 19th Zhejiang University Programming Contest

    感想: 今天三个人的状态比昨天计院校赛的状态要好很多,然而三个人都慢热体质导致签到题wa了很多发.最后虽然跟大家题数一样(6题),然而输在罚时. 只能说,水题还是刷得少,看到签到都没灵感实在不应该. ...

  8. Mergeable Stack 直接list内置函数。(152 - The 18th Zhejiang University Programming Contest Sponsored by TuSimple)

    题意:模拟栈,正常pop,push,多一个merge A B 形象地说就是就是将栈B堆到栈A上. 题解:直接用list 的pop_back,push_back,splice 模拟, 坑:用splice ...

  9. 152 - - G Traffic Light 搜索(The 18th Zhejiang University Programming Contest Sponsored by TuSimple )

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5738 题意 给你一个map 每个格子里有一个红绿灯,用0,1表示 ...

随机推荐

  1. PowerShell~执行策略的介绍

    首先看一下无法加载ps1脚本的解决方法 事实上也是由于策略导致的  解决方法主是开启对应的策略 set-ExecutionPolicy RemoteSigned 执行策略更改 执行策略可以防止您执行不 ...

  2. v-bind和v-on

    v-bind指令用于设置HTML属性:v-bind:href  缩写为 :href <a :href="{{url}}">aa</a> v-on 指令用于绑 ...

  3. Spring-bean(一)

    配置形式:基于xml文件的方式:基于注解的方式 Bean的配置方式:通过全类名(反射),通过工厂方法(静态工厂方法&实例工厂方法),FactoryBean 依赖注入的方式:属性注入,构造器注入 ...

  4. CF989C A Mist of Florescence

    思路: 有趣的构造题. 实现: #include <bits/stdc++.h> using namespace std; ][]; void fillin(int x, int y, c ...

  5. poj2677 Tour

    题意: 双调欧几里得旅行商问题. 思路: dp.定义dp[i][j](i <= j)为从点j从右向左严格按照x坐标递减顺序走到点1,之后再从点1从左向右严格按照x坐标递增的顺序走到点i,并且在此 ...

  6. ArcGIS二次开发之读取遥感图像像素值的做法

    作者:朱金灿 来源:http://blog.csdn.net/clever101 首先是读取遥感图像的R.G.B波段数据的做法.读取R.G.B波段数据的像素值主要通过IRaster接口的Read方法在 ...

  7. 7z解压参数

    7z.exe x D:/test/dwpath/xxx.zip -oD:/test/dwpath/ -aoa

  8. TFS2010单独安装配置tfs build server

    记录一下确实很磨人. 同样硬件和软件环境的两台服务器,其中一台服务器很久之前就配置好了tfs2010 build ,然后最近想再配置一台tfs build server,但是按照以前的配置流程始终提示 ...

  9. 设置QtreeWidget水平滚动条

    转载请注明出处:http://www.cnblogs.com/dachen408/p/7552603.html //设置treewidget水平滚动条 ui.treeWidget->header ...

  10. javascript中 if(变量)和if(变量==true)的区别

    if(判断表达式){执行内容} 如果判断表达式为true,则执行括号中的内容.这里,变量如果不为0,null,undefined,false,都会被处理为true.只要变量有非0的值或是某个对象,数组 ...