ZOJ - 3932 Handshakes 【水】
题目链接
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 【水】的更多相关文章
- ZOJ 3932 Handshakes
Last week, n students participated in the annual programming contest of Marjar University. Students ...
- ZOJ 3923 Handshakes
水题. 算一下每个人和之前的人握手次数+之后的人和这个人握手次数.取最大值. #include<cstdio> #include<cstring> #include<cm ...
- ZOJ 3594 年份水题 【注意:没有0年】
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #i ...
- zoj 3809 枚举水题 (2014牡丹江网赛 A题)
题目大意:给出一列取样的几个山的高度点,求山峰有几个? Sample Input 291 3 2 4 6 3 2 3 151 2 3 4 5Sample Output 30 # include < ...
- 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. ...
- 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 ...
- Handshakes(思维) 2016(暴力)
Handshakes Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Submit Sta ...
- zoj 3725
题意: n个格子排成一条直线,可以选择涂成红色或蓝色,问最少 m 个连续为红色的方案数. 解题思路: 应该是这次 ZOJ 月赛最水的一题,可惜还是没想到... dp[i] 表示前 i 个最少 m 个连 ...
- 水题 ZOJ 3875 Lunch Time
题目传送门 /* 水题:找排序找中间的价格,若有两个,选价格大的: 写的是有点搓:) */ #include <cstdio> #include <iostream> #inc ...
随机推荐
- LeetCode OJ--Search for a Range
http://oj.leetcode.com/problems/search-for-a-range/ 要求复杂度为O(lgn),用二分查找的思想. #include <iostream> ...
- js-无缝向上滚动
这种节奏经常用在相同布局内容多的地方,列如排行榜,新闻等地方.为了效率,在此做个笔记 HTML: <div id="divgd"> <div id="b ...
- Codeforces 946 C.String Transformation
C. String Transformation time limit per test 1 second memory limit per test 256 megabytes input st ...
- Skiing(最短路)
poj——3037 Skiing Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4921 Accepted: 1315 ...
- dubbo常见问题解答FAQ
常见问题解答 1. 如果服务注册不上怎么办? 2. 出现RpcException: No provider available for remote service异常怎么办? 3. 出现调用超时co ...
- pycharm的todo和fixme标记,标志为今后再做和bug点
使用方法,及查看方法: https://blog.csdn.net/xiemanR/article/details/73368440
- Hadoop 2.2.0集群搭建
一.环境说明 1.虚拟机平台:VMware10 2.Linux版本号:ubuntu-12.04.3-desktop-i386 3.JDK:jdk1.7.0_51 4.Hadoop版本号:2.2.0 5 ...
- [Algorithms] Quicksort algorithm using TypeScript
Quicksort (also called partition sort and pivot sort) is arguably the most used sorting algorithm. I ...
- karaf中利用Bundle引入外部log4j配置文件
环境准备: 1.在karaf_home下新建 config及logs目录 2.将mylog4j.properties拷贝到config文件夹下 查看log4j-1.2.17.jar/MANIFEST. ...
- Debian Customer PPA RFC (by quqi99)
作者:张华 发表于:2016-01-13版权声明:能够随意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 ( http://blog.csdn.net/quqi99 ) Pre ...