题意:
  Arya在学校有n个敌人(一串含有0,1的数字表示),有一个游戏规则,如果当天这n个敌人全部出席("1"代表出席,),即这串数字全部为"1",则Arya就输了,
否则,只要其中就一个"0",代表Arya赢,问你他连续赢得最多的天数?

分析:
  初始化ans(连续赢得最多的天数)为0,Arya连续赢天数day就加1,否则比较day与ans大小,ans = max(ans, day);

代码如下:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <iterator>
#include <vector> using namespace std; #define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 10000010
#define MAXM 1000010 int main()
{
int d;
int n;
int cnt, flag, pos;
while(cin>>n>>d)
{
string s;
int i, j;
pos = 0;
cnt = 0;
for(i = 1; i <= d; i++ )
{
flag = 0;
cin>>s;
for(j = 0; j < n; j++ )
{
if(s[j]-'0' == 0)
{
flag = 1;
break;
}
}
if(flag)
{
cnt += 1;
pos = max(pos, cnt);
}
else
cnt = 0;
}
printf("%d\n", pos);
}
return 0;
}

  

CodeForces 688A-Opponents的更多相关文章

  1. CodeForces 688A Opponents (水题)

    题意:给定 n 行数,让你找出连续最多的全是1的个数. 析:好像也没什么可说的,那就判断一下,并不断更新最大值呗. 代码如下: #include <iostream> #include & ...

  2. codeforces 688A A. Opponents(水题)

    题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  3. Codeforces Round #360 div2

    Problem_A(CodeForces 688A): 题意: 有d天, n个人.如果这n个人同时出现, 那么你就赢不了他们所有的人, 除此之外, 你可以赢他们所有到场的人. 到场人数为0也算赢. 现 ...

  4. Codeforces Round #360 (Div. 2) A. Opponents 水题

    A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...

  5. Codeforces Gym 100015A Another Rock-Paper-Scissors Problem 找规律

    Another Rock-Paper-Scissors Problem 题目连接: http://codeforces.com/gym/100015/attachments Description S ...

  6. Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题

    A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...

  7. [Codeforces Round #192 (Div. 2)] D. Biridian Forest

    D. Biridian Forest time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. Educational Codeforces Round 13 E. Another Sith Tournament 状压dp

    E. Another Sith Tournament 题目连接: http://www.codeforces.com/contest/678/problem/E Description The rul ...

  9. Codeforces Round #468 Div. 2题解

    A. Friends Meeting time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  10. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

随机推荐

  1. 十六、Java基础---------集合框架之Set

    写在前面的话,这篇文章在昨天就写好了,今天打开的时候一不小心将第二天的文章粘贴到了这篇文章,很不幸的是除了标题之外依然面目全非,今天带着沉痛的心情再来写这篇文章! 上篇文章介绍了Collection体 ...

  2. win api 实现 AES加密、解密

    WCHAR szPasswod[] = {L"goodpasswod" }; HCRYPTHASH hHash; HCRYPTPROV hCryptProv; HCRYPTKEY ...

  3. Arcgis Server 默认服务端口号修改方法

    本人安装Arcgis Server 10.2之后发布了一个地图服务,该服务默认使用的端口号是6080,本人使用的是教育网,使用教育网均能正常使用该服务,但是使用电信或者移动网络均不能正常访问该网站. ...

  4. android开源项目总汇

    http://www.cnblogs.com/wanqieddy/p/3709466.html

  5. CSS中的浮动问题

    有关于我们经常做的导航问题.我们如果想用ul>li来做导航的话,我是一般是用到浮动这个属性的. 也就是 float:left; 或者是 display:inline-block;  下边代码: ...

  6. 2016年12月20日 星期二 --出埃及记 Exodus 21:15

    2016年12月20日 星期二 --出埃及记 Exodus 21:15 "Anyone who attacks his father or his mother must be put to ...

  7. Python3基础 print 查看一个列表中存储的所有内容

    镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...

  8. python __file__ 与argv[0]

    在python下,获取当前执行主脚本的方法有两个:sys.argv[0]和__file__. sys.argv[0] 获取主执行文件路径的最佳方法是用sys.argv[0],它可能是一个相对路径,所以 ...

  9. js中的正则表达式

    一.正则中的汉字 常见的:/[^\x00-\x7F]+?/ /^[\u2E80-\u9FFF]+$/ 过滤汉字即是:string.replace(/^[\u2E80-\u9FFF]+$/g, &quo ...

  10. 了解less跟sass

    less官网:http://www.bootcss.com/p/lesscss/ LESS编写技巧分享:http://www.xuanfengge.com/less-writing-skills-sh ...