C. Day at the Beach---cf559
http://codeforces.com/problemset/problem/599/C
题目大意: 有n个城堡的高度 让你最多分成几个块 每个块排过序之后 整体是按照升序来的
分析: i之前的最大值只要小于等于i之后的最小值 ans++
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <math.h>
#include <ctype.h> using namespace std;
#define memset(a,b) memset(a,b,sizeof(a))
#define N 500100
typedef long long ll;
const double ESP = 1e-;
#define INF 0xfffffff int a[N];
int l[N],r[N]; int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
memset(l,);
memset(r,);
memset(a,);
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
l[i]=max(l[i-],a[i]);
}
r[n]=a[n];
for(int i=n-;i>;i--)
{
r[i]=min(r[i+],a[i]);
}
int sum=;
for(int i=;i<=n;i++)
{
if(l[i]<=r[i+])
sum++;
}
printf("%d\n",sum+);
}
return ;
}
C. Day at the Beach---cf559的更多相关文章
- Codeforces 599C Day at the Beach(想法题,排序)
C. Day at the Beach One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunate ...
- Codeforces Round #332 (Div. 2) C. Day at the Beach 线段树
C. Day at the Beach Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/599/p ...
- Codeforces Round #326 (Div. 2) D. Duff in Beach dp
D. Duff in Beach Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/588/probl ...
- CF- Day at the Beach
C. Day at the Beach time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces 599C. Day at the Beach 模拟
Day at the Beach time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- codeforces 587B B. Duff in Beach(dp)
题目链接: B. Duff in Beach time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Codeforces 553D Nudist Beach(二分答案 + BFS)
题目链接 Nudist Beach 来源 Codeforces Round #309 (Div. 1) Problem D 题目大意: 给定一篇森林(共$n$个点),你可以在$n$个点中选择若干个构 ...
- codeforces 553 D Nudist Beach
题意大概是.给出一个图,保证每一个点至少有一条边以及随意两点间最多一条边.非常显然这个图有众多点集,若我们给每一个点定义一个权值,那每一个点集都有一个最小权值点,如今要求出一个点集,这个点集的最小权值 ...
- C. Day at the Beach
codeforces 599c C. Day at the Beach One day Squidward, Spongebob and Patrick decided to go to the be ...
- Codeforces Round #332 (Div. 2)C. Day at the Beach 树状数组
C. Day at the Beach One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortuna ...
随机推荐
- NPM、nodeJS安装,grunt自动化构建工具学习总结
一:安装 npm是随nodeJs安装包一起安装的包管理工具,能解决NodeJS代码部署上的很多问题: 常见的使用场景有以下几种: 允许用户从NPM服务器下载别人编写的第三方包到本地使用. 允许用户从N ...
- 李开复:AlphaGo 若打败了世界冠军,意味着什么?
创新工场董事长李开复在知乎就AlphaGo与李世石的人机大战发表了自己看法,他认为四个月前的AlphaGo击败李世石基本不可能,不过这四个月AlphaGo进步很多,比赛应该很精彩.但是,无论这次结果如 ...
- Metinfo 5.3.19管理员密码重置漏洞复现
Metinfo 5.3.19管理员密码重置漏洞 操作系统:Windows 10专业版 kali linux 网站环境:UPUPW 5.3 使用工具:burpsuite 1.7 beta 漏洞分 ...
- rfcn讲解博客
http://www.cnblogs.com/lillylin/p/6277094.html ROI pooling操作的输入(对于C+1个类)是k^2*(C+1)*W' *H'(W'和H'是ROI的 ...
- SpringCloud版本介绍和SpringBoot的兼容性
Spring Cloud是一个由众多独立子项目组成的大型综合项目,每个子项目有不同的发行节奏,都维护着自己的发布版本号.Spring Cloud通过一个资源清单BOM(Bill of Material ...
- tornado框架基础02-输入和输出
01 输出 write bytes类型 class IndexHandler(tornado.web.RequestHandler): def get(self): self.write(b'Torn ...
- 《算法导论》 — Chapter 8 线性时间排序
序 到目前为止,关于排序的问题,前面已经介绍了很多,从插入排序.合并排序.堆排序以及快速排序,每一种都有其适用的情况,在时间和空间复杂度上各有优势.它们都有一个相同的特点,以上所有排序的结果序列,各个 ...
- 【BZOJ 1076】[SCOI2008]奖励关(期望)
Description 你正在玩你最喜欢的电子游戏,并且刚刚进入一个奖励关.在这个奖励关里,系统将依次随机抛出k次宝物, 每次你都可以选择吃或者不吃(必须在抛出下一个宝物之前做出选择,且现在决定不吃的 ...
- sysctl.conf文件配置详解
############################# net.inet.ip.sourceroute=0 net.inet.ip.accept_sourceroute=0 ########### ...
- 发布tomcate时报A configuration error occurred during startup.please verify the preference field with the prompat:null
发布tomcate时报A configuration error occurred during startup.please verify the preference field with the ...