zoukankan      html  css  js  c++  java
  • Codeforces Round #360 (Div. 2) A. Opponents 水题

    A. Opponents

    题目连接:

    http://www.codeforces.com/contest/688/problem/A

    Description

    Arya has n opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of them all. That means if one day at least one of Arya's opponents is absent at the school, then Arya will beat all present opponents. Otherwise, if all opponents are present, then they will beat Arya.

    For each opponent Arya knows his schedule — whether or not he is going to present on each particular day. Tell him the maximum number of consecutive days that he will beat all present opponents.

    Note, that if some day there are no opponents present, Arya still considers he beats all the present opponents.

    Input

    The first line of the input contains two integers n and d (1 ≤ n, d ≤ 100) — the number of opponents and the number of days, respectively.

    The i-th of the following d lines contains a string of length n consisting of characters '0' and '1'. The j-th character of this string is '0' if the j-th opponent is going to be absent on the i-th day.

    Output

    Print the only integer — the maximum number of consecutive days that Arya will beat all present opponents.

    Sample Input

    2 2
    10
    00

    Sample Output

    2

    Hint

    题意

    有一个人,要和n个人pk,要pk d天

    如果这一天所有人都来了,他就输了

    否则这个人就会说胜利

    问这个人最多能够连续胜利多少天

    题解:

    直接暴力做就好了……

    水题

    代码

    #include<bits/stdc++.h>
    using namespace std;
    
    string s;
    int main()
    {
        int n,d;
        scanf("%d%d",&n,&d);
        int ans = 0, tmp = 0;
        for(int i=0;i<d;i++){
            cin>>s;
            int flag = 0;
            for(int j=0;j<s.size();j++){
                if(s[j]=='0')
                    flag = 1;
            }
            if(flag==1)tmp=tmp+1;
            else tmp=0;
            ans = max(ans,tmp);
        }
        cout<<ans<<endl;
    }
  • 相关阅读:
    白鸦:互联网就是社区,液态的社区
    「芭比娃娃.com」
    做几个经营「人」的小网站,速速卖给大公司?
    关于工作与生活来自前hp总裁孙振耀
    新网站上线,酷狗狗 www.coogogo.com
    中国地摊联盟群组
    discuz!nt论坛搬迁后出错,提示:对象名 'dnt_templates' 无效
    时光.旅人
    const和readonly
    html.partial的一个bug?
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5631045.html
Copyright © 2011-2022 走看看