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 ...
随机推荐
- sqlachemy知识点
mysql语句 1.GROUP BY基本语法格式: GROUP BY关键字可以将查询结果按照某个字段或多个字段进行分组.字段中值相等的为一组.基本的语法格式如下: GROUP BY 属性名 [HAVI ...
- jQuery点击弹出层,弹出模态框,点击模态框消失
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...
- 验证您的Shell为Bash
内容介绍 在管理Linux服务器时,命令行操作无疑是最为耗时的环节.对大多数用户而言,这意味着将大量时间用于操作Bash shell. 尽管大多数发行版都提供默认的用户类型与root prompts, ...
- HDU2048 神、上帝以及老天爷
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2048 看书发现了这道题,刚开始没理解题意,以为是中奖的概率,---> 1/n 后来知道了是典型的错排 ...
- C++ | char* 在类中实践笔记
在C++中,当类中定义有char * 变量时,在传参,构造函数,复制构造函数如何创建及赋值,来一个简单的例子就明了: #include<iostream> #include<stri ...
- EIGRP-1-EIGRP的基础和演变
值得一提的是,在2013年,Cisco决定开放EIGRP的定义,并将其发布为IETFInternet草案,即RFC的前身:文档名称为draft-savage-eigrp.从此,基本的EIGRP不再是机 ...
- myeclipse 上安装 Maven
myeclipse 上安装 Maven3 环境准备: JDK 1.6 Maven 3.0.4 myeclipse 8.6.1 安装 Maven 之前要求先确定你的 JDK 已经安装配置完成.Mav ...
- vim 编辑器设置tab缩进
创建 ~/.vimrc文件,写入 set tabstop=4 ,保存 原文
- gogs迁移
windows->linux 之前gogs放在windows server2016中,需要迁移至linux docker中. 首先拉取gogs镜像 docker pull gogs/gogs 然 ...
- 牛客网Java刷题知识点之基本类型、引用类型
不多说,直接上干货! byte-short-int-long,方便识记.