답안 #180295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
180295 2020-01-08T16:35:04 Z Nightmar Money (IZhO17_money) C++17
100 / 100
778 ms 13432 KB
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <iomanip>
#include <unordered_map>

#define SWS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define ppb pop_back
#define ft first
#define sd second
#define readf freopen("input.txt", "r", stdin)
#define writef freopen("output.txt", "w", stdout)
#define files readf; writef

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int Z = 1000 * 1000;
const int N = (int)1e6 + 228;
const int INF = (int)1e9 + 5;
const int MOD = (int)1e9 + 7;

int a[N], t[4 * N];

void update(int v, int tl, int tr, int pos) {
    if (tl == tr) {
        t[v]++;
        return;
    }
    int mid = (tl + tr) / 2;
    if (pos <= mid) update(2 * v, tl, mid, pos);
    else update(2 * v + 1, mid + 1, tr, pos);
    t[v] = t[2 * v] + t[2 * v + 1];
}

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

int main() {
	SWS;
	srand(time(0));
	//files;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
	int ans = 0;
	for (int i = 1; i <= n; i++) {
        vector<int> kek;
        kek.pb(a[i]);
        int r = i + 1;
        while (r <= n) {
            if (a[r] < a[r - 1]) break;
            if (get(1, 1, Z, a[i] + 1, a[r] - 1)) break;
            kek.pb(a[r]);
            r++;
        }
        i = r - 1;
        ans++;
        for (int q : kek) {
            update(1, 1, Z, q);
        }
	}
	cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 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 504 KB Output is correct
7 Correct 2 ms 508 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 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 504 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 632 KB Output is correct
16 Correct 2 ms 632 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 504 KB Output is correct
7 Correct 2 ms 508 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 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 504 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 632 KB Output is correct
16 Correct 2 ms 632 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 3 ms 632 KB Output is correct
19 Correct 3 ms 632 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 0 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 504 KB Output is correct
7 Correct 2 ms 508 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 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 504 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 632 KB Output is correct
16 Correct 2 ms 632 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 3 ms 632 KB Output is correct
19 Correct 3 ms 632 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 0 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 504 KB Output is correct
33 Correct 2 ms 504 KB Output is correct
34 Correct 1 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 5 ms 2856 KB Output is correct
38 Correct 5 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 504 KB Output is correct
7 Correct 2 ms 508 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 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 504 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 632 KB Output is correct
16 Correct 2 ms 632 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 3 ms 632 KB Output is correct
19 Correct 3 ms 632 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 0 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 504 KB Output is correct
33 Correct 2 ms 504 KB Output is correct
34 Correct 1 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 5 ms 2856 KB Output is correct
38 Correct 5 ms 2808 KB Output is correct
39 Correct 208 ms 2468 KB Output is correct
40 Correct 343 ms 3932 KB Output is correct
41 Correct 167 ms 2092 KB Output is correct
42 Correct 154 ms 2296 KB Output is correct
43 Correct 116 ms 1912 KB Output is correct
44 Correct 430 ms 4612 KB Output is correct
45 Correct 435 ms 4584 KB Output is correct
46 Correct 416 ms 4696 KB Output is correct
47 Correct 438 ms 4472 KB Output is correct
48 Correct 423 ms 4472 KB Output is correct
49 Correct 597 ms 12540 KB Output is correct
50 Correct 597 ms 12636 KB Output is correct
51 Correct 598 ms 12540 KB Output is correct
52 Correct 589 ms 12568 KB Output is correct
53 Correct 601 ms 12616 KB Output is correct
54 Correct 603 ms 12664 KB Output is correct
55 Correct 738 ms 12664 KB Output is correct
56 Correct 740 ms 12536 KB Output is correct
57 Correct 734 ms 12664 KB Output is correct
58 Correct 778 ms 12644 KB Output is correct
59 Correct 743 ms 12584 KB Output is correct
60 Correct 735 ms 12408 KB Output is correct
61 Correct 735 ms 13432 KB Output is correct
62 Correct 750 ms 13420 KB Output is correct