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
Input
- 2 2
10
00Output
- 2
Input
- 4 1
0100Output
- 1
Input
- 4 5
1101
1111
0110
1011
1111Output
- 2
题意:
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 ...
随机推荐
- USB通讯协议
首先要了解USB枚举过程(自己百度) https://blog.csdn.net/MyArrow/article/details/8270029 USB通讯协议 0. 基本概念 一个[传输](控制.批 ...
- mongodb3.0 性能測试报告 二
mongodb3.0 性能測试报告 一 mongodb3.0 性能測试报告 二 mongodb3.0 性能測试报告 三 測试环境: 服务器:X86 pcserver 共6台 cpu: 单颗8核 ...
- sublime常用的插件
Sublime Text常用插件 1.Package Control 快捷键ctrl+~调出Sublime Text控制台,然后输入以下代码(Sublime Text3)安装Package Contr ...
- 版本控制器 git
摘要:版本控制器是码农必备的工具,很多常用的,像svn,git,cvs等,工作中用过svn,Tortoisehg,firefly,其实大同小异,现在简单介绍下git,以及它的一些常用命令. 在wind ...
- 【百度之星初赛A】路径交 LCA+线段树
[百度之星初赛A]路径交 Problem Description 给定一棵n个点的树,以及m条路径,每次询问第L条到第R条路径的交集部分的长度(如果一条边同时出现在2条路径上,那么它属于路径的交集). ...
- C++设计模式实现--策略(Strategy)模式
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/L_Andy/article/details/30489331 一. 举例说明 曾经做了一个程序,程序 ...
- ZFIND_ENHANCEMENT(找增强点-新)
REPORT ZFIND_ENHANCEMENT. *&-------------------------------------------------------------------- ...
- linux LVM:物理卷逻辑卷
逻辑卷管理器,当分区不够用的时候,可以新建一个更大的分区再复制进去,但是浪费时间.Lvm可以弹性调整分区大小,可以动态组合分区.分区大小固定了就无法调整, apt-get update & a ...
- Codeforces Round #304 (Div. 2) C. Soldier and Cards —— 模拟题,队列
题目链接:http://codeforces.com/problemset/problem/546/C 题解: 用两个队列模拟过程就可以了. 特殊的地方是:1.如果等大,那么两张牌都丢弃 : 2.如果 ...
- PYTHON 爬虫笔记一:爬虫基本原理梳理
知识点一:爬虫的基本原理梳理 一.什么是爬虫? 请求网站并提取数据的自动化程序 二.爬虫的基本流程 1:向服务器发起请求 通过HTTP库向目标站点发起请求,即发送一个Request,请求可以包含额外的 ...