Codeforces Round #547 (Div. 3) B.Maximal Continuous Rest
链接: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的更多相关文章
- Codeforces Round #547 (Div. 3) 题解
Codeforces Round #547 (Div. 3) 题目链接:https://codeforces.com/contest/1141 A,B咕咕了... C. Polycarp Restor ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #547 (Div. 3) G 贪心
https://codeforces.com/contest/1141/problem/G 题意 在一棵有n个点的树上给边染色,连在同一个点上的边颜色不能相同,除非舍弃掉这个点,问最少需要多少种颜色来 ...
- Codeforces Round #547 (Div. 3) F 贪心 + 离散化
https://codeforces.com/contest/1141/problem/F2 题意 一个大小为n的数组a[],问最多有多少个不相交的区间和相等 题解 离散化用值来做,贪心选择较前的区间 ...
- Codeforces Round #547 (Div. 3) D
http://codeforces.com/contest/1141/problem/D 题目大意: 鞋子匹配,用一个小写字母表示一种颜色.L[i]表示左脚的颜色,R[i]表示右脚的颜色,只有当L[i ...
- Codeforces Round #547 (Div. 3) D. Colored Boots
链接:https://codeforces.com/contest/1141/problem/D 题意: 给连个n长度的字符串. 求两个字符串相同字符对应位置的对数,并挨个打印. 字符:?可以代替任何 ...
- Codeforces Round #547 (Div. 3) A.Game 23
链接:https://codeforces.com/contest/1141/problem/A 题意: 给n和m,有两种操作:将n×2 或 n×3,求最少的乘法次数由n得到m. 不能得到时为-1. ...
随机推荐
- appcompat_v7出现红叉解决方法
右键属性,java build path 勾选Android5.5.2
- Android中点击事件的处理解析及常见问题
当我们手指按下时,Android采用层层传递-冒泡的方式处理点击事件.例如,现在公司来了个小项目,老板一看分配给经理做,经理一看分配给小组长,小组长一看好简单,分配给组员.如果在这个传递过 ...
- 为 Android 平台开发一个输入法
学习目标: 实现新的输入法 学习目的: 掌握Android输入法框架 学习收获: Android 1.5 新特色之一就是输入法框架(Input Method Framework,IMF),正是它的出现 ...
- hdu 1236 排名(排序)
题意:按成绩排序 思路:排序 #include<iostream> #include<stdio.h> #include<string.h> #include< ...
- C和C++语言&
#include "stdafx.h"#include "iostream"#include "animal.h"using namespa ...
- codevs 1046 旅行家的预算
传送门 1046 旅行家的预算 1999年NOIP全国联赛普及组NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold题解 题目描述 Des ...
- adb 调试命令
一.抓log 1. cat /proc/kmsg:抓kernel log(串口log) 2. 进入工程模式:adb shell am start -n com.mediatek.engineermo ...
- ABP 框架启程 及 ABP 翻译目录及传送门
准备动手写一套电商的系统,辗转收集了不少相关的开源项目,最后决定使用ABP作为起点. 在园子里好多人都在推广ABP.有个园友做了一个集合贴,方便大家使用 ABP集合贴 建议大家优先看 HK Zhan ...
- 如果后台用framset框架布局,session过期,整个跳出回 登录页面的方法
如果session过期了,登录页面会在framset框架的右边显示,只能用 js 来做,让整个框架跳出去: 然而,这里 js 必须要用“top”才可以,作用是让整个framset都跳转,直接用 win ...
- CodeForces 1098E. Fedya the Potter
题目简述:给定长度为$n \leq 5\times 10^4$的序列$a_1, a_2, \dots, a_n \leq 10^5$.将$\gcd(a_l, a_{l+1}, \dots, a_r) ...