0
点赞
收藏
分享

微信扫一扫

codeforces 688A Opponents


​​点击打开链接​​


A. Opponents



time limit per test



memory limit per test



input



output



n

consecutive

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



Input



n and d (1 ≤ n, d ≤ 100) — the number of opponents and the number of days, respectively.

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.



Examples



input



2 2 10 00



output



2



input



4 1 0100



output



1



input



4 5 1101 1111 0110 1011 1111



output



2



Note



d

1, 3 and 4 and his opponents will beat him on days 2 and 5. Thus, the maximum number of consecutive winning days is 2, which happens on days 3 and 4.





题意:有d次比赛,每次n个人,当n个人都来时,就输了,否则就赢,问连续能赢的最大次数。

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
typedef long long ll;
using namespace std;
const ll mod=100000000;
int main()
{
int n,d;
cin>>n>>d;
char str[110];
int ma=0,s=0,ans=0;
for(int i=0; i<d; i++)
{
cin>>str;
s=0;
int len=strlen(str);
for(int j=0; j<len; j++)
s+=str[j]-'0';
//cout<<s<<' '<<n<<endl;
if(s==n)
{
ma=max(ma,ans);
ans=0;
}
else
ans++;
}
ma=max(ma,ans);
cout<<ma<<endl;
//cout<<s<<' '<<n<<endl;
return 0;
}




举报

相关推荐

0 条评论