Codeforces #332 C. Day at the Beach (贪心)

原创 2015年11月21日 03:23:59

题意:

,,

分析:

f[i]:=a1ai
g[i]:=aian
fi<=gi+1ai,,

代码:

//
//  Created by TaoSama on 2015-11-21
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int n, a[N], f[N], g[N];

int main() {
#ifdef LOCAL
    freopen("C:\\Users\\TaoSama\\Desktop\\in.txt", "r", stdin);
//  freopen("C:\\Users\\TaoSama\\Desktop\\out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(scanf("%d", &n) == 1) {
        for(int i = 1; i <= n; ++i) {
            scanf("%d", a + i);
            f[i] = max(f[i - 1], a[i]);
        }
        g[n + 1] = INF;
        for(int i = n; i; --i)
            g[i] = min(g[i + 1], a[i]);

        int ans = 0;
        for(int i = 1; i <= n; ++i) {
//          pr(f[i]); prln(g[i + 1]);
            if(f[i] <= g[i + 1]) ++ans;
        }
        printf("%d\n", ans);
    }
    return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Codeforces Round #332 (Div. 2)C. Day at the Beach

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

Codeforces Round #332 (Div. 2) C. Day at the Beach

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

Codeforces Round#375 C:Polycarp at the Radio(贪心)

原题链接:点击打开链接 C. Polycarp at the Radio time limit per test 2 seconds memory ...

Codeforces Round #375 (Div. 2) C. Polycarp at the Radio 贪心+排序

贪心+排序 刚开始的时候理解题意错了,以为最小值尽可能大,最大值尽可能小, 但其实是中间贪心的过程中把最大值的 cnt[m-1].b的乐队变成最小值的乐队 cnt[0].b,直到 cnt[0].cnt...

CodeForces 723C-Polycarp at the Radio(模拟 贪心 vector乱搞)

C. Polycarp at the Radio time limit per test2 seconds memory limit per test256 megabytes inputsta...

Codeforces 553D Nudist Beach 优先队列 贪心

原题见CF 553D无向图G,n个点,m条边,k个坏点。 在G中选取子图S(可以不连通),S不能包含坏点。对于每个S中的点x,描述强度值I=x的属于S的邻居数/x的所有邻居数。I=x的属于S的邻居数...

贪心 CF 332 C 好题 赞

题目链接: http://codeforces.com/problemset/problem/332/C 题目意思: 有n个命令,要通过p个,某主席要在通过的p个中选择k个接受。 每个任务有两个值a...

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined) B. Bash's Big Day 数论+贪心

题意:给出n个数,选出尽可能多的数,使这些数的gcd不是1. 数论+贪心 选出尽可能多的数,使这些数的gcd不是1.,则它们的gcd是x,x >= 2, 所以可以枚举gcd的值,从2到1e5,然后枚举...

Codeforces Round #375 (Div. 2) C Polycarp at the Radio

C. Polycarp at the Radio time limit per test 2 seconds memory limit per test 256 megabytes ...

Codeforces 723 C. Polycarp at the Radio

题目链接:http://codeforces.com/problemset/problem/723/C C. Polycarp at the Radio time limi...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)