C. Day at the Beach---cf559
http://codeforces.com/problemset/problem/599/C
题目大意: 有n个城堡的高度 让你最多分成几个块 每个块排过序之后 整体是按照升序来的
分析: i之前的最大值只要小于等于i之后的最小值 ans++
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <math.h>
#include <ctype.h> using namespace std;
#define memset(a,b) memset(a,b,sizeof(a))
#define N 500100
typedef long long ll;
const double ESP = 1e-;
#define INF 0xfffffff int a[N];
int l[N],r[N]; int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
memset(l,);
memset(r,);
memset(a,);
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
l[i]=max(l[i-],a[i]);
}
r[n]=a[n];
for(int i=n-;i>;i--)
{
r[i]=min(r[i+],a[i]);
}
int sum=;
for(int i=;i<=n;i++)
{
if(l[i]<=r[i+])
sum++;
}
printf("%d\n",sum+);
}
return ;
}
C. Day at the Beach---cf559的更多相关文章
- 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 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 ...
- CF- Day at the Beach
C. Day at the Beach time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 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 ...
- Codeforces 553D Nudist Beach(二分答案 + BFS)
题目链接 Nudist Beach 来源 Codeforces Round #309 (Div. 1) Problem D 题目大意: 给定一篇森林(共$n$个点),你可以在$n$个点中选择若干个构 ...
- codeforces 553 D Nudist Beach
题意大概是.给出一个图,保证每一个点至少有一条边以及随意两点间最多一条边.非常显然这个图有众多点集,若我们给每一个点定义一个权值,那每一个点集都有一个最小权值点,如今要求出一个点集,这个点集的最小权值 ...
- 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 One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortuna ...
随机推荐
- .htaccess重写规则失败
开启mod_rewrite.so LoadModule rewrite_module libexec/apache2/mod_rewrite.so 重启服务 sudo apachectl restar ...
- IOS之UIStepper控件详解
在iOS5中新增了一个数字输入控件UIStepper,它可以递进式输入数量.UIStepper继承自UIControl,它主要的事件是UIControlEventValueChanged,每当它的值改 ...
- About the iOS File System
两个维度: 1)是否给用户使用: 2)是否持久存储. During installation of a new app, the installer creates a number of conta ...
- strict说明
- Win10 启动64位IE浏览器——修改注册表方法
修改注册表[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]下的: "TabProcGrowth"=DWOR ...
- C ++ _多线程笔记
#include<iostream>#include <thread>//创建线程需要添加的头文件 using namespace std;/*thread join(阻塞:主 ...
- 数位DP || Gym 101653R Ramp Number
每一位都大于等于前一位的数叫Ramp Number 给一个数,如果不是Ramp Number输出-1,如果是Ramp Number输出比它小的Ramp Number的个数 只和每一位上的数字有关 #i ...
- [LUOGU] P2187 小Z的笔记
看范围猜方程,应该是O(n)级别的 f[i]表示前i个合法的最小代价,转移需要枚举断点位置,O(n^2) f[i]表示前i个合法留下的最大个数,同时更新距离最近的26个字母的位置,O(n)转移 f[i ...
- 访问修饰词--Java
public(公共的) 权限: 完全公开 protected(受保护的) 权限: 对子类和同包中的其他类公开 default(默认的,可不写) 权限: 对同包中的其他类公开 private(私有的) ...
- python 2018/8/25
# 含多空格字符串的分割 hello = "hello python hello"print(a.split(" ")) # ['hello', 'python ...