답안 #758121

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
758121 2023-06-14T07:47:13 Z vjudge1 Money (IZhO17_money) C++17
100 / 100
1114 ms 61956 KB
#include"bits/stdc++.h"
using namespace std;
#define ll long long
const ll mod = 1000000007;

int b[1000001];

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    set<int> s;
    s.insert(-1);
    b[1] = 1e6;
    int l = 0, r = 1, ans = 1;
    while(r < n) {
        int g = *s.lower_bound(-a[l]) * -1;
        if(a[r] < a[r - 1] || a[r] > b[g]) {
            if(a[r - 1] != b[g]) {
                b[a[r - 1]] = b[g];
                s.insert(-a[r - 1]);
            }
            if(g != a[l])
                b[g] = a[l];
            for(int i = l; i < r - 1; i++) {
                if(a[i] == a[i + 1])
                    continue;
                b[a[i]] = a[i + 1];
                s.insert(-a[i]);
            }
            l = r;
            ans++;
        }
        r++;
    }
    cout << ans;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 328 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 328 KB Output is correct
36 Correct 0 ms 332 KB Output is correct
37 Correct 1 ms 852 KB Output is correct
38 Correct 1 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 328 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 328 KB Output is correct
36 Correct 0 ms 332 KB Output is correct
37 Correct 1 ms 852 KB Output is correct
38 Correct 1 ms 852 KB Output is correct
39 Correct 49 ms 5376 KB Output is correct
40 Correct 85 ms 8888 KB Output is correct
41 Correct 39 ms 4420 KB Output is correct
42 Correct 38 ms 4060 KB Output is correct
43 Correct 26 ms 2920 KB Output is correct
44 Correct 106 ms 10988 KB Output is correct
45 Correct 109 ms 10868 KB Output is correct
46 Correct 114 ms 11124 KB Output is correct
47 Correct 116 ms 10996 KB Output is correct
48 Correct 96 ms 11092 KB Output is correct
49 Correct 461 ms 33352 KB Output is correct
50 Correct 467 ms 33344 KB Output is correct
51 Correct 529 ms 33312 KB Output is correct
52 Correct 407 ms 33352 KB Output is correct
53 Correct 454 ms 33432 KB Output is correct
54 Correct 434 ms 33140 KB Output is correct
55 Correct 1086 ms 61876 KB Output is correct
56 Correct 1027 ms 61956 KB Output is correct
57 Correct 1114 ms 61932 KB Output is correct
58 Correct 1014 ms 61948 KB Output is correct
59 Correct 1028 ms 61836 KB Output is correct
60 Correct 1084 ms 61840 KB Output is correct
61 Correct 1112 ms 61932 KB Output is correct
62 Correct 1074 ms 61772 KB Output is correct