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 ...
随机推荐
- Reboot
目标是将浏览器的预设样式设为一致 Native font stack 本机字体堆栈 由于padding 及 border 会改变元素在运算后的宽度 此时的实际宽度为: width+左右padding ...
- 有关UPDATE操作的一些想法
我们平常写代码的时候,无疑都会接触大量的数据CURD操作.第一反应是这太简单了,那么你在编写UPDATE操作的时候是怎样的逻辑呢?比较下面两段伪代码: code exp.1 $SQL = " ...
- nginx 服务器并发优化
apache 提供的 ab 可以对服务器进行压力测试, 安装 ab: apt-get install apache2-utils 安装完后,ab 在目录 /usr/bin/ 下的. 执行: ab ...
- 移动web 的viewport设置注意事项的详细解释 六一快乐=-_-_
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- JavaScript中内置对象的一些属性及方法
Javascript对象总结 JS中内置了17个对象,常用的是Array对象.Date对象.正则表达式对象.string对象.Global对象 Array对象中常用方法: Concat():表示把几个 ...
- 牛客假日团队赛1 D.Promotion Counting
链接: https://ac.nowcoder.com/acm/contest/918/D 题意: Bessie the cow is helping Farmer John run the USA ...
- spring retry注解
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- 转 安装EBS前期检查工具 - RDA - Health Check / Validation Engine Guide
http://blog.itpub.net/35489/viewspace-1295028/ 参考文档 RDA - Health Check / Validation Engine Gu ...
- Java规则引擎drools:drt动态生成规则并附上具体项目逻辑
一 整合 由于本人的码云太多太乱了,于是决定一个一个的整合到一个springboot项目里面. 附上自己的项目地址https://github.com/247292980/spring-boot 以整 ...
- 数据库用户被锁怎么办,报the passord logon
–1.使用管理员用户登陆,查看用户状态: select username,account_status from dba_users; –2.修改用户状态: alter user base accou ...