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. Can't locate ExtUtils/MakeMaker.pm in @INC

    Can't locate ExtUtils/MakeMaker.pm in @INC 解决办法:yum install perl-devel

  2. 生成hprof文件,用MAT进行分析

    生成hprof文件可以在DDMS选中进程点击窗口左上角的"dump hprof file"按钮来直接生成,也可以通过在程序加代码中来生成 代码2: void generateHpr ...

  3. 在一台电脑上运行两个或多个tomcat

    在一台电脑上运行多个tomcat 在本例中,使用两个tomcat做示例   工具/原料   tomcat 安装好jdk,并且配置好环境变量 方法/步骤     首先去apache下载一个tomcat, ...

  4. Sublime Text插件的离线安装-使用htmlprettify美化您的HTML代码

    Sublime Text是广大程序员喜欢的文本编辑器,Jerry觉得它最强大之处在于开放的架构,有丰富的插件为其提供各种各样额外的功能. 作为前端开发人员,经常需要从网上复制粘贴一些代码然后做修改,因 ...

  5. 手把手教你免费把网站IP换成1.1.1.1/1.0.0.1

    近日,Cloudflare官方发文,与APNIC官方合作打算用IP1.1.1.1推出速度更快.私密性更强的DNS Cloudflare 运行全球规模最大.速度最快的网络之一. APNIC 是一个非营利 ...

  6. linux ABORT的应用详解

    NAME ABORT - 退出当前事务 SYNOPSIS ABORT [ WORK | TRANSACTION ] DESCRIPTION 描述 ABORT 回卷当前事务并且废弃所有当前事务中做的更新 ...

  7. PYTHON_DAY_02

    今日内容: 01 列表内置方法 '''''' ''' 列表: 定义: 在[]内,可以存放多个任意类型的值, 并以逗号隔开. 一般用于存放学生的爱好,课堂的周期等等... ''' # 定义一个学生列表, ...

  8. COM(Component Object Model)接口定义

    a COM interface is defined using a language called Interface Definition Language (IDL). The IDL file ...

  9. Java开发者写SQL时常犯的10个错误

        首页 所有文章 资讯 Web 架构 基础技术 书籍 教程 我要投稿 更多频道 » - 导航条 - 首页 所有文章 资讯 Web 架构 基础技术 书籍 教程 我要投稿 更多频道 » - iOS ...

  10. 485. Max Consecutive Ones@python

    Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1, ...