답안 #167670

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167670 2019-12-09T11:13:57 Z Rakhmand Money (IZhO17_money) C++14
100 / 100
739 ms 19396 KB
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//
 
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
 
#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer return cout << 0, 0;
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)
 
const int MXN = 1e6 + 200;
const long long MNN = 4e2 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;
 
typedef long long llong;
typedef unsigned long long ullong;
 
using namespace std;
 
int n, b[MXN], ans, t[4 * MXN];

int get(int v, int tl, int tr, int L, int R){
    if(L <= tl && tr <= R){
        return t[v];
    }
    if(tl > R || tr < L || L > R){
        return 0;
    }
    int tm = (tl + tr) / 2;
    return get(v * 2, tl, tm, L, R) + get(v * 2 + 1, tm + 1, tr, L, R);
}

void upd(int v, int tl, int tr, int ind, int x){
    if(tl == tr){
        t[v] = x;
        return ;
    }
    int tm = (tl + tr) / 2;
    if(ind <= tm){
        upd(v * 2, tl, tm, ind, x);
    }else{
        upd(v * 2 + 1, tm + 1, tr, ind, x);
    }
    t[v] = t[v * 2] + t[v * 2 + 1];
}

int main () {
    ios;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> b[i];
    }
    int l = 1, r = 1;
    while(l <= n){
        while(b[r] <= b[r + 1] && get(1, 1, 1000000, b[l] + 1, b[r + 1] - 1) == 0 && r + 1 <= n){
            r++;
        }
        ans ++;
        for(int i = l; i <= r; i++){
            upd(1, 1, 1000000, b[i], 1);
        }
        l = ++r;
    }
    cout << ans;
}
/*
 6
 3 6 4 5 1 2
 */
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 3 ms 632 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 508 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 760 KB Output is correct
26 Correct 2 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 3 ms 632 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 508 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 760 KB Output is correct
26 Correct 2 ms 760 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 632 KB Output is correct
33 Correct 2 ms 504 KB Output is correct
34 Correct 2 ms 632 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 504 KB Output is correct
37 Correct 4 ms 2808 KB Output is correct
38 Correct 4 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 3 ms 632 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 508 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 760 KB Output is correct
26 Correct 2 ms 760 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 632 KB Output is correct
33 Correct 2 ms 504 KB Output is correct
34 Correct 2 ms 632 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 504 KB Output is correct
37 Correct 4 ms 2808 KB Output is correct
38 Correct 4 ms 2808 KB Output is correct
39 Correct 178 ms 5772 KB Output is correct
40 Correct 304 ms 9208 KB Output is correct
41 Correct 139 ms 4600 KB Output is correct
42 Correct 154 ms 4476 KB Output is correct
43 Correct 100 ms 3576 KB Output is correct
44 Correct 386 ms 11256 KB Output is correct
45 Correct 374 ms 11256 KB Output is correct
46 Correct 363 ms 11532 KB Output is correct
47 Correct 366 ms 11240 KB Output is correct
48 Correct 356 ms 11356 KB Output is correct
49 Correct 546 ms 19368 KB Output is correct
50 Correct 545 ms 19396 KB Output is correct
51 Correct 564 ms 19268 KB Output is correct
52 Correct 529 ms 19264 KB Output is correct
53 Correct 547 ms 19200 KB Output is correct
54 Correct 533 ms 19232 KB Output is correct
55 Correct 702 ms 19192 KB Output is correct
56 Correct 722 ms 19196 KB Output is correct
57 Correct 739 ms 19148 KB Output is correct
58 Correct 712 ms 19236 KB Output is correct
59 Correct 694 ms 19320 KB Output is correct
60 Correct 724 ms 19212 KB Output is correct
61 Correct 688 ms 19320 KB Output is correct
62 Correct 686 ms 19224 KB Output is correct