Handshakes

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 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 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

2
3
0 1 1
5
0 0 1 1 1

Sample Output

2
3
题意:每个人进屋子里坐下,给出每个人和多少人握过手,让你去求一个人可能最多的握手次数;
解题思路:从后往前遍历,a[i]表示第i个人最多握多少次手,然后输出最多的那个,和学姐一起想这个题0.0,好有成就感0.0;
感悟:比赛真是太刺激了~
代码:
#include
#include
#include
using namespace std;
#define maxn 100010
int a[maxn];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        memset(a,0,sizeof(a));
        int n;
        scanf("%d",&n);
        for(int i=0;i
        {
            scanf("%d",&a[i]);
        }
        int ans=0,sum=0;
        for(int i=n-1;i>=0;i--)
        {
            if(a[i])sum++;
            a[i]+=(sum-1);
            ans=max(ans,a[i]);
        }
        printf("%d\n",ans);
    }
    return 0;
}

转载于:https://www.cnblogs.com/wuwangchuxin0924/p/5781559.html

SSL Report: aivisionxskino.com (8.163.27.185) Assessed on: Wed, 16 Jul 2025 08:47:44 UTC | Hide | Clear cacheScan Another » Assessment failed: No secure protocols supported Known Problems There are some errors that we cannot fix properly in the current version. They will be addressed in the next generation version, which is currently being developed. No secure protocols supported - if you get this message, but you know that the site supports SSL, wait until the cache expires on its own, then try again, making sure the hostname you enter uses the "www" prefix (e.g., "www.ssllabs.com", not just "ssllabs.com"). no more data allowed for version 1 certificate - the certificate is invalid; it is declared as version 1, but uses extensions, which were introduced in version 3. Browsers might ignore this problem, but our parser is strict and refuses to proceed. We'll try to find a different parser to avoid this problem. Failed to obtain certificate and Internal Error - errors of this type will often be reported for servers that use connection rate limits or block connections in response to unusual traffic. Problems of this type are very difficult to diagnose. If you have access to the server being tested, before reporting a problem to us, please check that there is no rate limiting or IDS in place. NetScaler issues - some NetScaler versions appear to reject SSL handshakes that do not include certain suites or handshakes that use a few suites. If the test is failing and there is a NetScaler load balancer in place, that's most likely the reason. Unexpected failure - our tests are designed to fail when unusual results are observed. This usually happens when there are multiple TLS servers behind the same IP address. In such cases we can't provide accurate results, which is why we fail. Common Error Messages Connect timed out - server did not respond to our connection request, sometimes before we are dynamically blocked when our tests are detected No route to host - unable to reach the server Unable to connect to server - failed to connect to the server, it usually happens due to firewall restrictions Connection reset - we got disconnected from the server Unrecognized SSL message, plaintext connection? - the server responded with plain-text HTTP on HTTPS port Received fatal alert: handshake_failure - this is either a faulty SSL server or some other server listening on port 443; if the SSL version of the web site works in your browser, please report this issue to us Failed to communicate with the secure server - No secure protocol supported. Possibly this server only supports a draft version of TLS 1.3 SSL Report v2.4.1 比较上一次的信息,再分析下原因
07-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值