题目链接:

A. Opponents

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Examples
input
2 2
10
00
output
2
input
4 1
0100
output
1
input
4 5
1101
1111
0110
1011
1111
output
2

题意:

全是1的时候就是失败的时候,找最长的0的序列;

 思路:

 水题

 AC代码:

//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio> using namespace std;
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<''||CH>'';F= CH=='-',CH=getchar());
for(num=;CH>=''&&CH<='';num=num*+CH-'',CH=getchar());
F && (num=-num);
}
int stk[], tp;
template<class T> inline void print(T p) {
if(!p) { puts(""); return; }
while(p) stk[++ tp] = p%, p/=;
while(tp) putchar(stk[tp--] + '');
putchar('\n');
} const LL mod=1e9+;
const double PI=acos(-1.0);
const LL inf=1e18;
const int N=1e4+;
const int maxn=;
const double eps=1e-; char str[][];
int a[];
int main()
{ int n,d;
read(n);read(d);
for(int i=;i<=d;i++)
{
scanf("%s",str[i]);
int flag=;
for(int j=;j<n;j++)
{
if(str[i][j]=='')flag=;
}
if(flag)a[i]=;
}
int ans=,len=;
for(int i=;i<=d;i++)
{
if(a[i])
{
len++;
}
else
{
ans=max(ans,len);
len=;
}
}
ans=max(ans,len);
cout<<ans<<"\n"; return ;
}

最新文章

  1. HTML两张图片叠加问题的进一步修改
  2. ZOJ 1015 Fishing Net(弦图判定)
  3. IE9 JSON未定义
  4. 重绘panel控件,实现panel的阴影效果
  5. 谁会是 Zabbix 和 Nagios 的继任者?
  6. automake使用
  7. Redis的Time Event与File Event的微妙关系
  8. ZOJ 3795 Grouping
  9. ERROR 1114 (HY000): The table &#39;adv_date_tmp&#39; is full(Mysql临时表应用)
  10. 再回首,Java温故知新(十一):Java反射
  11. JavaScript高级程序设计(学习笔记)
  12. 【bzoj4571&amp;&amp;SCOI2016美味】
  13. QPropertyAnimation实现图形,控件的旋转和位移动画,尤其是旋转
  14. 通过Weeman+Ettercap配合拿下路由器管理权限
  15. mac 全角/半角标点符号切换
  16. C语言 &#183; 8皇后问题
  17. 查看CPU核数和内存
  18. Linux进程共享通信 -- mmap实现
  19. JSP之静态include指令、动态Include指令
  20. Python之路----列表推导式和生成器的表达式

热门文章

  1. 【Kubernetes】Kubernetes的Service外部访问方式:NodePort和LoadBalancer
  2. 什么是Service Mesh?
  3. Django 的信号 &amp; Flask 的信号
  4. BZOJ1740: [Usaco2005 mar]Yogurt factory 奶酪工厂
  5. BZOJ1700: [Usaco2007 Jan]Problem Solving 解题
  6. SUSE linux使用zypper 安装软件-比yum更好用
  7. UITextInputMode currentInputMode is deprecated. 警告的解决
  8. SQL SERVER 2012 第五章 创建和修改数据表 の CREATE语句
  9. zookeeper一二三
  10. 【Nginx】定时器事件