zoukankan      html  css  js  c++  java
  • ZOJ

    题目链接

    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
    ", ans);
        }
  • 相关阅读:
    程序员外包网站
    网络测试
    数据库系统在线网课
    字体
    正则表达式测试工具
    豆瓣Top250数据可视化
    前端模板
    豆瓣Top250电影爬取
    PyCharm激活码
    爬虫禁止访问解决方法(403)
  • 原文地址:https://www.cnblogs.com/Dup4/p/9433161.html
Copyright © 2011-2022 走看看