预处理一下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的更多相关文章

  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 587B B. Duff in Beach(dp)

    题目链接: B. Duff in Beach time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  4. codeforce 599C Day at the Beach

    Bi表示第i个块,那么就是说Bi max ≤ Bi+1 min,又因为Bi min ≤ Bi max, 因此只要判断前缀的最大值是否小于等于后缀. #include<bits/stdc++.h& ...

  5. [cf 599C] Day at the Beach

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

  6. C. Day at the Beach

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

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

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

  9. Codeforces 553D Nudist Beach(二分答案 + BFS)

    题目链接 Nudist Beach 来源  Codeforces Round #309 (Div. 1) Problem D 题目大意: 给定一篇森林(共$n$个点),你可以在$n$个点中选择若干个构 ...

随机推荐

  1. 如何正确理解和使用 Activity的4种启动模式

    关于Activity启动模式的文章已经很多,但有的文章写得过于简单,有的则过于注重细节,本文想取一个折中,只关注最重要和最常用的概念,原理和使用方法,便于读者正确应用. Activity的启动模式有4 ...

  2. 第一章 熟悉Objective -C 编写高质量iOS与OS X代码的52 个有效方法

    第一章 熟悉Objective -C   编写高质量iOS与OS  X代码的52 个有效方法   第一条: 了解Objective-C 语言的起源 关键区别在于 :使用消息结构的语言,其运行时所应执行 ...

  3. XSS漏洞扫描经验分享

    关于XSS漏洞扫描,现成的工具有不少,例如paros.Acunetix等等,最近一个项目用扫描工具没有扫出漏洞,但还是被合作方找出了几个漏洞.对方找出的漏洞位置是一些通过javascript.ajax ...

  4. Jquery中children与find之间的区别

    <table id="tb"> <tr> <td>0</td> <td>1</td> <td>2 ...

  5. MFC隐藏在黑暗之中的大坑

    大坑一:CDC会随着窗口状态的改变而改变 void K5::OnPaint() { CDC *pDC=this->GetDC(); //CDC最好设为局部变量 ... this->Rele ...

  6. Oracle————存储过程与函数

    存储过程存储过程参数模式包括IN.OUT. IN OUT. IN(默认参数模式):表示当存储过程别调用时,实参值被传递给形参:形参起变量作用,只能读该参数,而不能修改该参数.IN模式参数可以是变量或表 ...

  7. IIS实现HTTPS的主机名绑定

    默认情况下,IIS中HTTPS 绑定是无法指定主机名的解决办法:通过手工修改 IIS 配置来实现主机头绑定.打开如下位置的文件. C:\Windows\system32\inetsrv\config\ ...

  8. scrapy example

    scrapy example scrapy with pycharm import win32api 出现ImportError: DLL load failed 错误的解决方法 pip instal ...

  9. 常用的网络通信命令--write.wall.mesg.mail

    write 作用:给其它的在线用户发送消息 格式:write  [ 用户名 ]  [ tty ] 注意点:使用之前最好使用 who 命令查看当前在线用户,tty 为端口号 使用举例: 在光标闪烁的地方 ...

  10. 分分钟钟学会Python - 函数(function)

    函数(function) 1 基本结构 本质:将多行代码拿到别处并起个名字,以后通过名字就可以找到这行代码并执行 应用场景: 代码重复执行 代码量很多超过一屏,可以选择通过函数进行代码的分割 写代码方 ...