链接: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. leetcode 748. Shortest Completing Word

    Find the minimum length word from a given dictionary words, which has all the letters from the strin ...

  2. SCOI2017 游记(AFO)

    SCOI2017 游记(AFO) Day 0 上午模拟考,又tm用暴力a了一道题,心情舒畅.(要是省选也这样该有多好,2333) 晚上又去吃了什么不知名的东西,自己都忘了,总之好像很好吃的样子. Da ...

  3. HDU3183 A Magic Lamp —— 贪心(单调队列优化)/ RMQ / 线段树

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3183 题解: 方法一:贪心. 在草稿纸上试多几次可以知道,删除数字中从左到右最后一位递增(可以等于)的 ...

  4. 分布式session之token解决方案实现

    基于令牌(Token)方式实现Session解决方案,因为Session本身就是分布式共享连接 用token代替session 废话不多说,看项目: pom.xml <project xmlns ...

  5. 关于Javascript中声明变量、函数的笔记

    一.概念 1.变量声明 在JavaScript中,变量一般通过var关键字(隐式声明,let关键字声明除外)进行声明,如下通过var关键字声明a,b,c三个变量(并给其中的a赋值): var a=1, ...

  6. codeforces 467B Fedor and New Game 解题报告

    题目链接:http://codeforces.com/contest/467/problem/B 题目意思:有 m + 1 个 player 和 n 种类型的 soldiers.每个player被赋予 ...

  7. Normalize.css 与传统的 CSS Reset 有哪些区别?

    CSS Reset 是革命党,CSS Reset 里最激进那一派提倡不管你小子有用没用,通通给我脱了那身衣服,凭什么你 body 出生就穿一圈 margin,凭什么你姓 h 的比别人吃得胖,凭什么你 ...

  8. flask logger

    Flask uses standard Python logging. All Flask-related messages are logged under the 'flask' logger n ...

  9. node.js版本管理(Win) --- nvm-window

    目录 1. 安装 2. 使用 1. 安装 去往Git链接:https://github.com/coreybutler/nvm-windows. 点击下载链接: 选择第一个nvm-noinstall. ...

  10. shell函数(调用、返回值,返回值获取)

    Shell函数返回值,常用的两种方式:return,echo 1) return 语句shell函数的返回值,可以和其他语言的返回值一样,通过return语句返回.示例1: [devadmin@swa ...