D - Opponents
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
Input2 2
10
00Output2Input4 1
0100Output1Input4 5
1101
1111
0110
1011
1111Output2
题意:
Arya与n个对手每天打一架,当这一天n个对手全部来时Arya就输了,否则就是Arya赢,求最大连胜天数。
附AC代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std; int main( )
{
int n,d,i,j,k=,c=,l=,max=;
char a[];
scanf("%d %d",&n,&d);
for(i=;i<d;i++)
{
c=;
scanf("%s",a);
l=strlen(a);
for(j=;j<l;j++)
{
if(a[j]=='')
{
c+=;
}
}
if(c!=l)
{
k+=;
}
if(k>max)
{
max=k;
}
if(c==l)
{
k=;
}
}
printf("%d\n",max);
return ;
}
D - Opponents的更多相关文章
- Codeforces Round #360 (Div. 2) A. Opponents 水题
A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...
- codeforces 688A A. Opponents(水题)
题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- CodeForces 688A Opponents (水题)
题意:给定 n 行数,让你找出连续最多的全是1的个数. 析:好像也没什么可说的,那就判断一下,并不断更新最大值呗. 代码如下: #include <iostream> #include & ...
- 【CodeForces688A】Opponents
[思路分析] 比较水的模拟题 具体见代码吧 #include<iostream> #include<cstdio> #include<algorithm> usin ...
- Google云平台对于2014世界杯半决赛的预测,德国阿根廷胜!
由于本人是个足球迷,前段日子Google利用自己云平台预测世界杯八进四的比赛并取得了75%的正确率的事情让我振动不小.虽然这些年一直听说大数据的预测和看趋势能力如何如何强大,但这次的感受更加震撼,因为 ...
- blade and soul Group Combos
Group Combos A martial artist always make friends along their way. They learn how to work and fight ...
- blade and soul races guide
Race Four races are available for those who wish to choose the path of martial arts: the careful Gon ...
- MOTION-MATCHING IN UBISOFT’S FOR HONOR翻译
http://www.gameanim.com/2016/05/03/motion-matching-ubisofts-honor/ Introducing For Honor with a vide ...
- 套题 codeforces 360
A题:Opponents 直接模拟 #include <bits/stdc++.h> using namespace std; ]; int main() { int n,k; while ...
随机推荐
- 电源滤波电容在PCB中正确的布线方法!
电源滤波电容在PCB中正确的布线方法! 错误的电源滤波电容布线方法. 1.很多人朋友在设计的时候喜欢加宽这个电源的走,这个是一个很好的方法,但是他们如果一不小心就会忽略电容的布线. 下面的电容布线看起 ...
- vim 宏的使用
1. 基本使用 q[a-z] 开始录制宏 q 停止录制 @[a-z] 使用宏 @@ 调用最近使用的宏 22@[a-z] 多次重放宏 2. 宏的执行方式 串行方式:5@[a-z] 宏内包含向下一个目标 ...
- python--内置函数补充
内置函数补充 基础数据类型相关 和数字相关:数据类型: bool 布尔 int 整型 float 浮点 complex 复数 只有在强转中会用进制转换: bin() 二进制转换 比如0b开头表示的是二 ...
- 看完此文,妈妈还会担心你docker入不了门?
本文在个人技术博客不同步发布,详情可猛戳 亦可扫描屏幕右侧二维码关注个人公众号,公众号内有个人联系方式,等你来撩... 上周对象突然心血来潮说想养个小宠物,我问想养啥她又说随便,你看着办!!!这我 ...
- kubernetes之创建基于名称空间的内存和cpu限额示例
系列目录 首先我们创建一个名称空间 kubectl create namespace quota-mem-cpu-example 创建资源配额 apiVersion: v1 kind: Resourc ...
- 动态控制body最小高度
//动态控制body最小高度 var windowHeight = $(document).height() - 164; $(".body-content").css({ &qu ...
- tomcat 代码集
Tomcat类是整个tomcat的起点,负责加载所有的配置信息以及把配置信息解析转换成tomcat组件对象. Context addWebapp(String contextPath, String ...
- Oracle SQL_杂记
1. 查询当前用户角色,当前用户下的表权限以及所有用户表权限 desc user_role_privs;select * from user_role_privs; desc user_tab_pri ...
- 两个经典的文件IO程序示例
前言 本文分析两个经典的C++文件IO程序,提炼出其中文件IO的基本套路,留待日后查阅. 程序功能 程序一打印用户指定的所有文本文件,程序二向用户指定的所有文本文件中写入数据. 程序一代码及其注释 # ...
- PHP中的面向对象 中的类(class)
2.11 上午讲的是面向对象中的类(class),一个非常抽象的概念, 类里面成员的定义有 public$abc; private$abc(私有变量): protect $abc(受保护的变量): 下 ...