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. [未读]backbonejs应用程序开发

    买来就没有动过,那阵子刚好离职找工作,之后学backbone的劲头就过去了= =

  2. Ionic之存储信息、取出存储信息、注销存储信息

    每一个app软件在登录的时候,都会本地存储登录信息,需要用到数据的时候,就直接在本地获取,而不是每一次应用的时候都要请求到服务器来验证登录信息,减少服务器的负担.所以在设计混合HTML5 移动应用程序 ...

  3. ES-Apache Lucene

    前言 在介绍Lucene之前,我们来了解相关的历史. 有必要了解的Apache Apache软件基金会(也就是Apache Software Foundation,简称为ASF)是专门为运作一个开源软 ...

  4. 在CentOS上把Git从1.7.1升级到1.7.12.4

    在CentOS上把Git从1.7.1升级到1.7.12.4 摘要:本文记录了在CentOS 6.3上,把Git从1.7.1升级到1.7.12.4的过程. 1. 概述 在我做的一个项目中,最近我对生产服 ...

  5. expand - 把 tab 符转换为空格符

    总览 (SYNOPSIS) ../src/expand [OPTION]... [FILE]... 描述 (DESCRIPTION) 把 各文件 FILE 中的 tab 符 转换为 空格符, 然后 写 ...

  6. project .mpp 查看当天工作任务 1.选择自己 2.选择起始和终止时间 就显示当天的任务了

    project .mpp 查看当天工作任务 1.选择自己 2.选择起始和终止时间 就显示当天的任务了

  7. 一个Lucene.Net的Demo

    今天突然想来看一下全文检索,于是就了解了一下Lucene.Net,然后把公司目前的产品表拿来练手,写了这么个Demo. 先看一下Demo的代码 public class ProductReposito ...

  8. Java中的线程安全和非线程安全以及锁的几个知识点

    1. 线程安全就是多线程访问时,采用了加锁机制,当一个线程访问该类的某个数据时,进行保护,其他线程不能进行访问直到该线程读取完,其他线程才可使用.不会出现数据不一致或者数据污染. 线程不安全就是不提供 ...

  9. [POJ] 1191 [LUOGU] P1436 棋盘分割

    那个均方差,可以通过展开.合并Σ,发现最终只有Xi^2会对答案造成影响,其他都是定值,所以求出最小的和的平方就行. 其实这才是这题最难的部分,以下都是码农部分. f[x1][y1][x2][y2][k ...

  10. (9) openssl enc(对称加密)

    对称加密工具,了解对称加密的原理后就很简单了,原理部分见下文. openssl   enc  -ciphername   [-in filename]   [-out filename]   [-pa ...