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

  1. 2
  2. 3
  3. 0 1 1
  4. 5
  5. 0 0 1 1 1

Sample Output

  1. 2
  2. 3

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

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<algorithm>
  4. #include<iostream>
  5. #include<cmath>
  6. using namespace std;
  7. const int N=100000+10;
  8. int a[N];
  9. int main()
  10. {
  11. int t,n,i,maxx;
  12. scanf("%d",&t);
  13. while(t--)
  14. {
  15. maxx=0;
  16. scanf("%d",&n);
  17. for(i=1; i<=n; i++)
  18. {
  19. scanf("%d",&a[i]);
  20. if(a[i])
  21. maxx++;
  22. if(a[i]>maxx)
  23. maxx=a[i];
  24. }
  25. printf("%d\n",maxx);
  26. }
  27. return 0;
  28. }

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. cpp extern 关键字用法

    语法说明: extern 可以置于变量或者函数前,以标示变量或者函数的在别的文件中定义,提示编译器遇到此变量和函数后,在其他模块中寻找其定义.此外extern也可用来进行链接指定. 即 extern ...

  2. session共享方法

    session数据保存在memcached,redis这种内存数据库内 memcache比较简单,使用的场景比较多.redis支持的数据类型多.而且数据具有期限,和session和期限可以配合使用 通 ...

  3. 【转】log4j的日志

    一.Log4j配置 第一步:加入log4j-1.2.8.jar到lib下. 第二步:在CLASSPATH下建立log4j.properties.内容如下: 放在src下的话就不用配置 否则得去web. ...

  4. CSS实现文字旋转/实现角标

    主要用到属性transform:rotate(-30deg) example: .divedittable .project-tag div { width: 43px; line-height: 4 ...

  5. Java断点续传(基于socket与RandomAccessFile的简单实现)

    Java断点续传(基于socket与RandomAccessFile的简单实现) 这是一个简单的C/S架构,基本实现思路是将服务器注册至某个空闲端口用来监视并处理每个客户端的传输请求. 客户端先获得用 ...

  6. P3374 【模板】树状数组 1 单点修改与区间查询

    题目描述 如题,已知一个数列,你需要进行下面两种操作: 1.将某一个数加上x 2.求出某区间每一个数的和 输入输出格式 输入格式: 第一行包含两个整数N.M,分别表示该数列数字的个数和操作的总个数. ...

  7. 【经验总结】OSG 安装配置

    对于普通用户推荐直接下载安装包配置.如有特殊需求或想了解编译过程可参考网上文章自己编译后配置.(通常建议使用第一种方法即可) 本人安装经验: 失败:自己系统64位,VS2010 32位,开始自己动手编 ...

  8. iOS 自己手动添加编译警告

    文/青花瓷的平方(简书作者)原文链接:http://www.jianshu.com/p/b2e30cad2a0d著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”. 缘由 上一次生产环境我们 ...

  9. cacti支持中文办法

    1.yum groupinstall "chinese support" 2. 登陆Cacti,在主页的左边点击setting,选择paths页(console>>se ...

  10. Win2D 入门教程 VB 中文版

    继续填坑!又一个c#教程变为vb! 这是我翻译的Win2D教程,链接保留了微软原版的. 如果文档有问题,可以在 https://github.com/Nukepayload2/Win2dDocVB发 ...