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$个点中选择若干个构 ...
随机推荐
- java操作Excel、PDF文件
java操作Excel.PDF文件 分享者:Vashon 分享来源:CSDN博客 下面这些是在开发中用到的一些东西,有的代码贴的不是完整的,只是贴出了关于操作EXCEL的代码: jxl是一个*国人写的 ...
- SQL Server 查询锁表和接锁表
SQL Server 查询锁表 select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) as tableNa ...
- 自定义Jquery分页插件
/** * 功能说明:jPager 分页插件 * 参数说明:pages:[] 分页的控件个数 @id:显示分页的div ID,@showSelectPage: 是否显示当前分页的条目过滤下拉框 * @ ...
- hdu5739Fantasia(多校第二场1006) 割点+逆元
Fantasia Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Proble ...
- nginx 安全配置文档
1.配置文档中有多处明确写出了nginx的配置文件路径,该路径是测试环境中的路径,线上系统的nginx配置文件与文档中所写的路径可能不一样,在进行相关配置时,应以线上配置文件的实际路径为准. 线上系统 ...
- JVM 内存区域方面的面试题
https://mp.weixin.qq.com/s/TpCElutqVSt7PAzjrGz12w 写在前面(常见面试题) 基本问题 •介绍下 Java 内存区域(运行时数据区)•Java 对象的创建 ...
- run_debug和run_demo的区别
run_demo:给一张图,直接生成测试出来的框,输入不用给gt框 run_debug:生成ap值,生成的图片既有gt框也有测试得到的结果框 run_demo的源码demo_test放在example ...
- luogu 1968 美元汇率
https://www.luogu.org/problemnew/show/P1968 定义二维数组f[ ][ ],f[i][1]表示在第i天将马克变为美元,f[i][2]表示在第i天将美元变为马克. ...
- mysql 数据库 show命令
MySQL中有很多的基本命令,show命令也是其中之一,在很多使用者中对show命令的使用还容易产生混淆,本文汇集了show命令的众多用法. 1. show tables或show tables fr ...
- css 图片等宽等高
html <div class="autoimg"> <img src="xxx.jpg" /> </div> css .a ...