CodeForces 599C Day at the Beach
预处理一下i到n的最小值。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std; int n;
int a[+];
int Min[+];
int ans; int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++) scanf("%d",&a[i]);
Min[n]=a[n]; Min[n+]=1e9+;
for(int i=n-;i>=;i--) Min[i]=min(Min[i+],a[i]); int pre=-; for(int i=;i<=n;i++)
{
pre=max(pre,a[i]);
if(pre<=Min[i+])
{
ans++;
pre=-;
}
}
printf("%d\n",ans);
return ;
}
CodeForces 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 587B B. Duff in Beach(dp)
题目链接: B. Duff in Beach time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- codeforce 599C Day at the Beach
Bi表示第i个块,那么就是说Bi max ≤ Bi+1 min,又因为Bi min ≤ Bi max, 因此只要判断前缀的最大值是否小于等于后缀. #include<bits/stdc++.h& ...
- [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 ...
- 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 ...
- Codeforces 553D Nudist Beach(二分答案 + BFS)
题目链接 Nudist Beach 来源 Codeforces Round #309 (Div. 1) Problem D 题目大意: 给定一篇森林(共$n$个点),你可以在$n$个点中选择若干个构 ...
随机推荐
- http://bbs.chinaunix.net/thread-1463276-1-1.html
http://bbs.chinaunix.net/thread-1463276-1-1.html
- Java递归调用改成非递归
在java语言中,使用递归调用时,如果过多的调用容易造成java.lang.StackOverflowError即栈溢出和程序执行过慢.这是一个潜在Bug和影响程序执行效率问题,需要谨慎使 ...
- Hessian矩阵与牛顿法
Hessian矩阵与牛顿法 牛顿法 主要有两方面的应用: 1. 求方程的根: 2. 求解最优化方法: 一. 为什么要用牛顿法求方程的根? 问题很多,牛顿法 是什么?目前还没有讲清楚,没关系,先直观理解 ...
- 职业生涯手记——电视剧剧情O.O
很多电视剧.偶像剧.电影里出现过一些场景,从来没想过狗血剧情是来源于现实.. 直到上周一开始,我慢慢相信了.. 事情是这样的. 我们小组有个组员H,从上周一开始他每天都去公司的座机电话接1~2个电话, ...
- Android(java)学习笔记158:多线程断点下载的原理(JavaSE实现)
1. 为什么需要多线程下载? 服务器的资源有限,同时的平均地分配给每个客户端.开启的线程越多抢占的服务的资源就越多,下载的速度就越块. 2. 下载速度的限制条件? (1)你的电脑手机宽带的带宽 ...
- window.onload和DOMContentLoaded的区别
一.何时触发这两个事件? 1.当 onload 事件触发时,页面上所有的DOM,样式表,脚本,图片,flash都已经加载完成了. 2.当 DOMContentLoaded 事件触发时,仅当DOM加载完 ...
- G7或变G6+1?特朗普七国峰会箱友军开炮
今日导读 G7 峰会刚召开完毕,德国总理默克尔发的一张照片就迅速火遍全球.照片中她身体前倾,像是在质问特朗普,而后者则双手交叉胸前,我自岿然不动,这张火药味十足的照片不禁让人脑补当时剑拔弩张的气氛.到 ...
- 高德地图api之location定位
关于定位,分为GPS定位和网络定位.本文将详细描述的浏览器定位,属于网络定位.这是一种通过使用高德JS-API来实现位置定位.城市定位的方法,包含了IP定位,检索等多种网络定位方式.如果您的手机支持G ...
- 读懂CommonJS的模块加载
叨叨一会CommonJS Common这个英文单词的意思,相信大家都认识,我记得有一个词组common knowledge是常识的意思,那么CommonJS是不是也是类似于常识性的,大家都理解的意思呢 ...
- jQuery判断一个元素是否为另一个元素的子元素(或者其本身)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head& ...