题目链接

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3932

题意

给出 N 个人,然后 1-N 然后 从 1 - N 一个一个的进,每个人 进去 都可以在在座的人握手,然后给出那个人握手的次数

要求出 握手次数的最大值

思路

只要进来的人握手次数>=1 那么 本来已经在区域内的人 那个当前这个人的握手次数 就是其给出的握手次数,本来已经在区域内的人握手次数都+1,因为都是有可能的

然后实际发现 ,可以FOR 一遍 不断更新当前状态和已经在区域内的状态 就可以了

AC代码

#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctype.h>
#include <algorithm>
#include <deque>
#include <vector>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits> #define CLR(a) memset(a, 0, sizeof(a))
#define pb push_back using namespace std; const int maxn = 1e5 + 5; int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int n;
scanf("%d", &n);
int id, ans = 0;
for (int i = 0; i < n; i++)
{
scanf("%d", &id);
if(id)
ans = max(ans + 1, id);
}
printf("%d\n", ans);
}

ZOJ - 3932 Handshakes 【水】的更多相关文章

  1. ZOJ 3932 Handshakes

    Last week, n students participated in the annual programming contest of Marjar University. Students ...

  2. ZOJ 3923 Handshakes

    水题. 算一下每个人和之前的人握手次数+之后的人和这个人握手次数.取最大值. #include<cstdio> #include<cstring> #include<cm ...

  3. ZOJ 3594 年份水题 【注意:没有0年】

    #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #i ...

  4. zoj 3809 枚举水题 (2014牡丹江网赛 A题)

    题目大意:给出一列取样的几个山的高度点,求山峰有几个? Sample Input 291 3 2 4 6 3 2 3 151 2 3 4 5Sample Output 30 # include < ...

  5. ZOJ 3932 Deque and Balls

    There are n balls, where the i-th ball is labeled as pi. You are going to put n balls into a deque. ...

  6. ZOJ 2679 Old Bill ||ZOJ 2952 Find All M^N Please 两题水题

    2679:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1679 2952:http://acm.zju.edu.cn/onli ...

  7. Handshakes(思维) 2016(暴力)

    Handshakes Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Sta ...

  8. zoj 3725

    题意: n个格子排成一条直线,可以选择涂成红色或蓝色,问最少 m 个连续为红色的方案数. 解题思路: 应该是这次 ZOJ 月赛最水的一题,可惜还是没想到... dp[i] 表示前 i 个最少 m 个连 ...

  9. 水题 ZOJ 3875 Lunch Time

    题目传送门 /* 水题:找排序找中间的价格,若有两个,选价格大的: 写的是有点搓:) */ #include <cstdio> #include <iostream> #inc ...

随机推荐

  1. CocoaPods | iOS详细使用说明

    一:介绍 在iOS开发中,经常会使用到第三方库,[CocoaPods](https://github.com/CocoaPods/CocoaPods)可以用来方便的统一管理这些第三方库. 下面就和大家 ...

  2. Codeforces 932 C.Permutation Cycle-数学 (ICM Technex 2018 and Codeforces Round #463 (Div. 1 + Div. 2, combined))

    C. Permutation Cycle   time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  3. Java方法中传值和引用传递的问题(转)

    说明:标题其实说法是错误的.Java中只有值传递,没有引用传递. ... ... //定义了一个改变参数值的函数 public static void changeValue(int x) { x = ...

  4. app 检查更新和更新

    第一种,手动检查 ////  Harpy.h//  Harpy////  Created by Arthur Ariel Sabintsev on 11/14/12.//  Copyright (c) ...

  5. n个平面把空间最多分成几个部分?

    题目: n个平面把空间最多分成几个部分? 解答: 1条直线可以把平面分成2部分,2条直线最多可以把平面分成4部分, 3条直线最多可以把平面分成几部分,4条直线呢?你能不能想出n条直线最多可以把平面分成 ...

  6. 投资人王刚口述:滴滴如何用八十万成为百亿美金公司? zz

    作者|李好福布斯杂志中文版采编 阿里巴巴前高管.滴滴打车天使投资人王刚近日在杭州接受了<福布斯>独家专访,讲述了集齐“阿里的人.百度的技术.腾讯的钱”的滴滴如何从八十万启动资金,在三年内成 ...

  7. iOS -- MBProgressHUB

    高级: http://www.jianshu.com/p/485b8d75ccd4 //只有小菊花 - (void)indeterminateExample { // Show the HUD on ...

  8. Mac -- 安装及使用Docker

    安装这三个软件. 有两个安装包:  和  安装完使用挺简的. 更多内容官网查看: https://docs.docker.com/

  9. Linux Distribution

    来自为知笔记(Wiz)

  10. 使用纯CSS3实现一个日食动画

    日食现象是月亮挡在了地球和太阳之间,也就是月亮遮挡住了太阳. 所以要构造日食,我们须要2个对象:一个代表月亮,一个代表太阳. <div class="eclipse sun" ...