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. 百度AI图片识别

    官方文档:http://ai.baidu.com/tech/ocr/general

  2. 使用js页面添加或删除标签

    // 添加var container = document.getElementById('divAudio');container.appendChild(audio); // 删除var cont ...

  3. The Knuth-Morris-Pratt Algorithm in my own words(转)

    origianl For the past few days, I’ve been reading various explanations of the Knuth-Morris-Pratt str ...

  4. python numpy 判断ndarray 中是否有 nan

    numpy.isnan(myarray).any() 下面讨论了哪一种方法的速度最快 reference: stackoverflow.com/questions/911871/detect-if-a ...

  5. 2017-10-20 NOIP模拟赛

    Lucky Transformation #include<iostream> #include<cstring> #include<cstdio> using n ...

  6. 一切从这里起始(左耳听风 ARTS 6号小组 week 1)

    ARTS 具体要求: 1.每周至少做一个 leetcode 的算法题2.阅读并点评至少一篇英文技术文章3.学习至少一个技术技巧4.分享一篇有观点和思考的技术文章 1.Algorithm Two Sum ...

  7. ROS上利用usb_cam读取摄像头图像

    电脑需要有USB3.0的接口 我使用的环境为:Ubuntu16.04LTS ROS版本是kinetic 一.usb_cam驱动的安装 1.创建ROS工作空间 mkdir -p myros/src cd ...

  8. Webpack+Vue构建项目

    第一步:单纯的搭建出来我们的项目,并且通过webpack打包一个bundle.js然后运行起来 步骤: 1.建立项目必要的文件和文件夹(见截图) 2.配置webpack.develop.config. ...

  9. 把查询出来的结果进行修改再赋值给list

    List<RivBillNoPatternL> list = this.jdbcTemplate.getJdbcOperations().query(sqlSb.toString(), p ...

  10. Carryon的字符串

    I J I: Carryon的字符串 时间限制: 1 s      内存限制: 128 MB      提交 我的状态 题目描述 Carryon最近喜欢上了一些奇奇怪怪的字符,字符都是英文小写字母,但 ...