codeforce 599C Day at the Beach
Bi表示第i个块,那么就是说Bi max ≤ Bi+1 min,又因为Bi min ≤ Bi max,
因此只要判断前缀的最大值是否小于等于后缀。
#include<bits/stdc++.h>
using namespace std; typedef long long ll; const int maxn = 1e5+;
int h[maxn], n;
int mn[maxn]; //#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
scanf("%d", &n);
for(int i = ; i < n; i++){
scanf("%d", h+i);
}
mn[n-] = h[n-];
for(int i = n-; i >= ; i--){
mn[i] = min(mn[i+],h[i]);
}
int mx = h[], ans = ;
for(int i = ; i < n; i++){
if(mx <= mn[i]) ans++;
mx = max(h[i], mx);
}
printf("%d\n", ans);
return ;
}
codeforce 599C Day at the Beach的更多相关文章
- 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 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 599C Day at the Beach
预处理一下i到n的最小值. #include<cstdio> #include<cstring> #include<cmath> #include<algor ...
- [cf 599C] Day at the Beach
题意:有n个数,将其分组使整个数列排序后每组中的数仍在该组中,求最多的分组数. 代码很易懂 #include <iostream> #include <algorithm> # ...
- C. Day at the Beach
codeforces 599c C. Day at the Beach One day Squidward, Spongebob and Patrick decided to go to the be ...
- Codeforce - Street Lamps
Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is ...
- Codeforce Round #216 Div2
e,还是写一下这次的codeforce吧...庆祝这个月的开始,看自己有能,b到什么样! cf的第二题,脑抽的交了错两次后过了pretest然后system的挂了..脑子里还有自己要挂的感觉,果然回头 ...
- 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 ...
随机推荐
- oracle数据库rownum讲解(转)
https://blog.csdn.net/qq_40794266/article/details/78698321
- 51nod1428(优先队列)
题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1428 题意:中文题诶- 思路:贪心 问最少要多少教室就是求最多 ...
- 2017-10-1 清北刷题冲刺班p.m
一道图论好题 (graph) Time Limit:1000ms Memory Limit:128MB 题目描述 LYK有一张无向图G={V,E},这张无向图有n个点m条边组成.并且这是一张带权图 ...
- mui 从子页面返回至父页面,同时刷新父页面
今天在写页面的时候,有一个需求,就是新闻列表项的时候,会显示出浏览次数,点击进入页面的时候,也会有浏览次数,且浏览次数比点击之前的已经+1了.那么用户返回到新闻列表页的时候,浏览次数应该更新了. mu ...
- docker默认存储空间用完情况下,做迁移数据
由于docker默认存放数据路径为/var/lib/docker,但运行了一段时间后,发现/var/lib/docker下的目录文件过大,导致此分区空间不够用.通过以下方法,解决该问题. 如何避免: ...
- java线程池之一:创建线程池的方法
在Java开发过程中经常需要用到线程,为了减少资源的开销,提高系统性能,Java提供了线程池,即事先创建好线程,如果需要使用从池中取即可,Java中创建线程池有以下的方式, 1.使用ThreadPoo ...
- Proxy模式(代理[延迟]模式)
Proxy?? Proxy是"代理人"的意思,它指的是代替别人进行工作的人.代理实际上就是使用委托的机制,在代理的过程中你可以做点其他的事情,然后再来执行被代理对象的代码. 知识储 ...
- (转)Linux 命令(40): wc 命令
Linux系统中的wc(Word Count)命令的功能为统计指定文件中的字节数.字数.行数,并将统计结果显示输出. 原文:http://blog.jobbole.com/109925/ http:/ ...
- YARN的架构及原理
1. YARN产生背景 MapReduce本身存在着一些问题: 1)JobTracker单点故障问题:如果Hadoop集群的JobTracker挂掉,则整个分布式集群都不能使用了. 2)JobTrac ...
- 屏蔽“您目前使用的Discuz!程序有新版本发布,请及时升级!”提示
在/discuz/source/admincp目录下找到文件:admincp_main.php 找到第49行: if($_G['uid'] && $_G['member']['allo ...