답안 #1117947

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1117947 2024-11-24T12:34:54 Z Icelast Money (IZhO17_money) C++17
100 / 100
790 ms 61988 KB
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn = 2*1e5+5, INF = 1e9+9;
void solve(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    vector<int> f(n+1, INF);
    f[0] = 0;
    int last = 0;
    a[0] = INF;
    set<int> s;
    for(int i = 1; i <= n; i++){
        if(a[i] >= a[i-1]){
            auto it = s.lower_bound(a[i]);
            int L;
            if(it != s.begin()){
                L = *prev(it);
            }else{
                L = 0;
            }
            int l = last, r = i;
            while(l <= r){
                int mid = (l+r)/2;
                if(a[mid] >= L){
                    r = mid-1;
                }else{
                    l = mid+1;
                }
            }
            if(a[l] < L){
                f[i] = INF;
                continue;
            }
            f[i] = f[l-1]+1;
        }else{
            for(int j = last; j < i; j++){
                s.insert(a[j]);
            }
            last = i;
            f[i] = f[i-1]+1;
        }
    }
    cout << f[n];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 504 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 504 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 504 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 504 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 1 ms 508 KB Output is correct
37 Correct 1 ms 508 KB Output is correct
38 Correct 1 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 504 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 504 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 1 ms 508 KB Output is correct
37 Correct 1 ms 508 KB Output is correct
38 Correct 1 ms 592 KB Output is correct
39 Correct 45 ms 7240 KB Output is correct
40 Correct 76 ms 11848 KB Output is correct
41 Correct 36 ms 5928 KB Output is correct
42 Correct 35 ms 5448 KB Output is correct
43 Correct 25 ms 3920 KB Output is correct
44 Correct 88 ms 14848 KB Output is correct
45 Correct 88 ms 14720 KB Output is correct
46 Correct 87 ms 15108 KB Output is correct
47 Correct 79 ms 14940 KB Output is correct
48 Correct 76 ms 14984 KB Output is correct
49 Correct 273 ms 33336 KB Output is correct
50 Correct 242 ms 33408 KB Output is correct
51 Correct 280 ms 33276 KB Output is correct
52 Correct 252 ms 33352 KB Output is correct
53 Correct 246 ms 33532 KB Output is correct
54 Correct 283 ms 33400 KB Output is correct
55 Correct 688 ms 61776 KB Output is correct
56 Correct 646 ms 61752 KB Output is correct
57 Correct 730 ms 61792 KB Output is correct
58 Correct 722 ms 61748 KB Output is correct
59 Correct 706 ms 61772 KB Output is correct
60 Correct 737 ms 61772 KB Output is correct
61 Correct 790 ms 61988 KB Output is correct
62 Correct 775 ms 61736 KB Output is correct