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;
}
    原文作者:qscqesze
    原文地址: https://www.cnblogs.com/qscqesze/p/5631045.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞