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的更多相关文章

  1. Codeforces 599C Day at the Beach(想法题,排序)

    C. Day at the Beach One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunate ...

  2. 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 ...

  3. CodeForces 599C Day at the Beach

    预处理一下i到n的最小值. #include<cstdio> #include<cstring> #include<cmath> #include<algor ...

  4. [cf 599C] Day at the Beach

    题意:有n个数,将其分组使整个数列排序后每组中的数仍在该组中,求最多的分组数. 代码很易懂 #include <iostream> #include <algorithm> # ...

  5. C. Day at the Beach

    codeforces 599c C. Day at the Beach One day Squidward, Spongebob and Patrick decided to go to the be ...

  6. Codeforce - Street Lamps

    Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is ...

  7. Codeforce Round #216 Div2

    e,还是写一下这次的codeforce吧...庆祝这个月的开始,看自己有能,b到什么样! cf的第二题,脑抽的交了错两次后过了pretest然后system的挂了..脑子里还有自己要挂的感觉,果然回头 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. UPC11073(DP,思维)

    #include<bits/stdc++.h>using namespace std;long long dp[507][507];const long long mod = 998244 ...

  2. cf835(预处理 + 记忆化dp)

    题目链接: http://codeforces.com/contest/835/problem/D 题意: 定义 k 度回文串为左半部分和右半部分为 k - 1 度的回文串 . 给出一个字符串 s, ...

  3. Docker容器构建过程的安全性分析

    来源:嘶吼专业版 ID:Pro4hou DevOps概念的流行跟近些年微服务架构的兴起有很大关系,DevOps是Dev(Development)和Ops(Operations)的结合,Dev负责开发, ...

  4. tp5.1 手动引入外部类库

    use think\facade\Env; require_once Env::get('ROOT_PATH')."extend/PHPExcel/Classes/PHPExcel.php& ...

  5. 使用navicat把一个数据库的表导入到另外一个数据库

    第一步:右击数据库名,选择数据传输 第二步:全选要导的数据库表 第三步:选择目标中的数据库,然后开始就可以了

  6. BZOJ4552(二分+线段树)

    要点 序列是n个不同的数,则新学到的一种策略就是二分这个位置的答案,然后可以上下调. 神奇地只关注大于还是小于mid并赋值0.1,这样m个操作的排序就能用线段树维护了! #include <cs ...

  7. java——方法重载与重写、构造方法、this关键字、static关键字、strictfp关键字、类的导入

    Java SE5新增加@Override注解,它并不是关键字,但是可以把它当作关键字使用.当你想要覆写(重写)某个方法时,可以选择添加这个注解,在你不留心重载而并非覆写了该方法时,编译器就会生成一条错 ...

  8. LeetCode 069 Sqrt(x) 求平方根

    Implement int sqrt(int x).Compute and return the square root of x.x is guaranteed to be a non-negati ...

  9. 二维hash

    题目描述 给出一个n * m的矩阵.让你从中发现一个最大的正方形.使得这样子的正方形在矩阵中出现了至少两次.输出最大正方形的边长. 输入描述: 第一行两个整数n, m代表矩阵的长和宽: 接下来n行,每 ...

  10. /sbin/int的启动及后续进程的启动_3

    转载自: http://www.ruanyifeng.com/blog/2013/08/linux_boot_process.html 半年前,我写了<计算机是如何启动的?>,探讨BIOS ...