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的更多相关文章

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

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

  4. CF- Day at the Beach

    C. Day at the Beach time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

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

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

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

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

  8. codeforces 553 D Nudist Beach

    题意大概是.给出一个图,保证每一个点至少有一条边以及随意两点间最多一条边.非常显然这个图有众多点集,若我们给每一个点定义一个权值,那每一个点集都有一个最小权值点,如今要求出一个点集,这个点集的最小权值 ...

  9. C. Day at the Beach

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

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

随机推荐

  1. 在colab上运行style-transfer

    1,  打开chrome浏览器,输入以下网址,打开风格转换主文件 https://colab.research.google.com/github/Hvass-Labs/TensorFlow-Tuto ...

  2. Knockout-了解Observable与computed

    KO是什么? KO不是万能的,它的出现主要是为了方便的解决下面的问题: UI元素较多,用户交互比较频繁,需要编写大量的手工代码维护UI元素的状态.样式等属性? UI元素之间关系比较紧密,比如操作一个元 ...

  3. js由浅入深理解

    隐式转换 + - num - 0 把num转换成number: num + "" 把num转换成字符串: ------------------------------------- ...

  4. uva10570 Meeting with Aliens

    先证明把每次i放到i位置最后次数最少:感觉,可以,用归纳法? //在序列后再加一个相同的序列,就可以模拟用各个数字开头的情况了每个位置不对的只需要换一次54123 ,5固定->41235变成12 ...

  5. iview table的render()函数基本的用法

    render:(h,params) => { return h(" 定义的元素 ",{ 元素的性质 }," 元素的内容"/[元素的内容]) }

  6. java内存模型(线程共享部分)

    1.元空间(MetaSpace)与永久代(PermGen)的区别? ----> 1.1 元空间使用的是本机内存(这样的好处是,可以使用的内存空间变大了,没有OutOfMemoryError:Pe ...

  7. tornado框架基础02-输入和输出

    01 输出 write bytes类型 class IndexHandler(tornado.web.RequestHandler): def get(self): self.write(b'Torn ...

  8. 杭电 1596 find the safest road (最小路径变形求最大安全度)

    Description XX星球有很多城市,每个城市之间有一条或多条飞行通道,但是并不是所有的路都是很安全的,每一条路有一个安全系数s,s是在 0 和 1 间的实数(包括0,1),一条从u 到 v 的 ...

  9. 数据结构实验7:实现二分查找、二叉排序(查找)树和AVL树

    实验7 学号:      姓名:     专业: 7.1实验目的 (1) 掌握顺序表的查找方法,尤其是二分查找方法. (2) 掌握二叉排序树的建立及查找. 查找是软件设计中的最常用的运算,查找所涉及到 ...

  10. JSP默认选中下拉框的某一项

    注意<c:if>标签要写在<option>标签里面 <select id="salesInventory_${s.index}" style=&quo ...