链接:https://codeforces.com/contest/1141/problem/B

题意:

给n个数,0代表工作,1代表休息,求能连续最大的休息长度。

可以连接首尾。

思路:

求普通连续,当第一个时间和最后一个时间都休息的时候加上去判断一下。

代码:

#include <bits/stdc++.h>
using namespace std; typedef long long LL; const int MAXN = 2e5;
int r[MAXN]; int main()
{
int flag = 1;
int n, o;
int pos = 1;
int res = 0;
cin >> n;
for (int i = 1;i <= n;i++)
{
cin >> o;
if (o == 1)
r[pos]++;
else
pos++;
if (i == 1 && o == 0)
flag = 0;
if (i == n && o == 0)
flag = 0;
res = max(res, r[pos]);
}
if (flag)
res = max(res, r[1] + r[pos]);
cout << res << endl; return 0;
}

  

Codeforces Round #547 (Div. 3) B.Maximal Continuous Rest的更多相关文章

  1. Codeforces Round #547 (Div. 3) 题解

    Codeforces Round #547 (Div. 3) 题目链接:https://codeforces.com/contest/1141 A,B咕咕了... C. Polycarp Restor ...

  2. Codeforces Round #506 (Div. 3) C. Maximal Intersection

    C. Maximal Intersection time limit per test 3 seconds memory limit per test 256 megabytes input stan ...

  3. Codeforces Round #198 (Div. 2) B. Maximal Area Quadrilateral

    B. Maximal Area Quadrilateral time limit per test 1 second memory limit per test 256 megabytes input ...

  4. E. Superhero Battle Codeforces Round #547 (Div. 3) 思维题

    E. Superhero Battle time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Codeforces Round #547 (Div. 3) G 贪心

    https://codeforces.com/contest/1141/problem/G 题意 在一棵有n个点的树上给边染色,连在同一个点上的边颜色不能相同,除非舍弃掉这个点,问最少需要多少种颜色来 ...

  6. Codeforces Round #547 (Div. 3) F 贪心 + 离散化

    https://codeforces.com/contest/1141/problem/F2 题意 一个大小为n的数组a[],问最多有多少个不相交的区间和相等 题解 离散化用值来做,贪心选择较前的区间 ...

  7. Codeforces Round #547 (Div. 3) D

    http://codeforces.com/contest/1141/problem/D 题目大意: 鞋子匹配,用一个小写字母表示一种颜色.L[i]表示左脚的颜色,R[i]表示右脚的颜色,只有当L[i ...

  8. Codeforces Round #547 (Div. 3) D. Colored Boots

    链接:https://codeforces.com/contest/1141/problem/D 题意: 给连个n长度的字符串. 求两个字符串相同字符对应位置的对数,并挨个打印. 字符:?可以代替任何 ...

  9. Codeforces Round #547 (Div. 3) A.Game 23

    链接:https://codeforces.com/contest/1141/problem/A 题意: 给n和m,有两种操作:将n×2 或 n×3,求最少的乘法次数由n得到m. 不能得到时为-1. ...

随机推荐

  1. [NOIP2011提高组day2]-3-观光公交

    3.观光公交 (bus.cpp/c/pas) [问题描述] 风景迷人的小城 Y 市,拥有 n 个美丽的景点.由于慕名而来的游客越来越多,Y 市特意安排了一辆观光公交车,为游客提供更便捷的交通服务.观光 ...

  2. 网页中的title中设置图标

    每个网页中title旁边的图标是怎么实现的呢?像这个百度的图标,今天做了一下,很简单,下面记录一下. 做一个图片,一般的图标都可以,把图标后缀改为.ico格式就OK了,放在项目路径下,保证该图片可以被 ...

  3. ansible操作模块相关

    1. 查看模块可用参数命令 ansible-doc -s module_name

  4. C++的逐过程和逐语句的区别

    1.逐语句是指在遇到函数调用语句的时候进入到函数内部执行. 2.逐过程是指在遇到函数调用语句时把函数当作一条语句执行.

  5. 用 Java 抓取优酷、土豆等视频

    1. [代码][JavaScript]代码  import org.jsoup.Jsoup;import org.jsoup.nodes.Document;import org.jsoup.nodes ...

  6. Android studio 添加assets文件夹

    我们知道Eclipse创建的工程默认是有个assets文件夹的,但是Android studio默认没有帮我们创建,那么我们就自己创建一个就好啦. (1)手动创建 在项目的顶部有个下拉,默认选择的是A ...

  7. Oracle数据常用操作

    将用逗号隔开字段拆分成两行: select * from mp_fs_file_info a,dm_process_upload b where instr(b.attachment,a.file_i ...

  8. python 基础之第八天--字典相关

    zx #####################创建字典###################################### In [11]: dict([('name','bob'),('a ...

  9. python装饰器执行顺序

    . python 装饰器 1) 2层装饰器 def decorator(func): # TODO def wrapper(*args, **kwargs): # TODO func(*args, * ...

  10. PHP错题误区

    1,$bool = TRUE;echo gettype($bool);  //这个输出类型:booleanecho is_string($bool);  //这个用echo是不能输出布尔型的,只有va ...