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);
        }
  • 相关阅读:
    文件上传案例_Socket_测试
    Linux的小整理(入门)
    full stack 第一天
    基础考题 试题
    shell语法
    网络管理
    图像类
    定时储存
    网络管理
    磁盘管理
  • 原文地址:https://www.cnblogs.com/Dup4/p/9433161.html
Copyright © 2011-2022 走看看