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. ZooKeeper读书笔记

    <ZooKeeper读书笔记> 1.Zookeeper是什么?Zookeeper是一个典型的分布式数据一致性的解决方案,分布式应用可以基于它实现诸如数据发布/订阅.负载均衡.命名服务.分布 ...

  2. vue下axios和fetch跨域请求

    1.在config的index.js下面进行常用跨域配置代码:proxyTable: { '/apis': { //使用"/api"来代替"http://xxxx.cn& ...

  3. Linux下搭建DHCP服务器

    一.DHCP所需软件包 dhcp-common-4.1.1-34.Pl.el6.centos.x86_64 dhcp-4.1.1-34.pl.el6.centon.x86_64 二.编辑主配置文件 v ...

  4. mybatis+oracle 完成插入数据库,并将主键返回的注意事项

    mybatis+oracle 完成插入数据库,并将主键返回的注意事项一条插入语句就踩了不少的坑,首先我的建表语句是: create table t_openapi_batch_info( BATCH_ ...

  5. uva11491 Erasing and Winning

    边读入边处理 优化了速度一开始有想错了的地方.处理输入有点想用stringstream, 的问题在于他把字符串连续的数字作为一个整体,遇到空格才分开,所以不适用 #include<cstdio& ...

  6. 如何在一次请求中通过JS中获取Url中的参数

    从A跳转到B,携带参数 例如: /pc/B.jsp?item=123456 B页面在js可以直接用 var item='${param.item}'; 这样就拿到啦 还有一种方法 定义一个函数   f ...

  7. django模板系统的基本原则

    写模板,创建template对象,创建 context ,调用render()方法

  8. STL || HDU 1894 String Compare

    如果一个词包含再另一个词的前面(前缀),是一对前缀,求一共有多少对 *解法:STL万岁 #include<string>:https://www.cnblogs.com/SZxiaochu ...

  9. js实现复制input的value到剪切板

    <button class="button-code button-copy">复制链接</button><script> $(".b ...

  10. python猜年龄游戏升级版

    猜年龄游戏升级版 要求:允许用户最多尝试3次,每尝试3次后,如果还没猜对,就问用户是否还想继续玩,如果回答Y,就继续让其猜3次,以此往复,如果回答N,就退出程序,如何猜对了,就直接退出 age = 1 ...