답안 #494951

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494951 2021-12-17T17:28:47 Z Ronin13 Money (IZhO17_money) C++14
100 / 100
950 ms 58044 KB
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define inf 1e9+1
#define linf 1e18+1
using namespace std;
const int NMAX=1e6+1;


void solve(){
    int n;cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)cin>>a[i];
    set<int>st;
    st.insert(inf);
    int l=1;
   int r=2;
    int cnt=0;
    while(r<=n){

        int x;
        if(st.size()==0)x=inf;
        else x=*st.upper_bound(a[l]);
        if((a[r]>=a[r-1])&&(x>=a[r])){
            r++;
        }
        else{
            cnt++;
            for(int i=l;i<r;i++){
                st.insert(a[i]);
            }
            l=r;
            r++;
        }
    }
    cnt++;
    cout<<cnt<<"\n";
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int test=1;//cin>>test;
    while(test--)solve();
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 304 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 304 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 0 ms 308 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 1 ms 208 KB Output is correct
23 Correct 1 ms 316 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 304 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 0 ms 308 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 1 ms 208 KB Output is correct
23 Correct 1 ms 316 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 0 ms 208 KB Output is correct
27 Correct 0 ms 208 KB Output is correct
28 Correct 1 ms 208 KB Output is correct
29 Correct 0 ms 312 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 0 ms 320 KB Output is correct
35 Correct 0 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 0 ms 208 KB Output is correct
38 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 304 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 0 ms 308 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 1 ms 208 KB Output is correct
23 Correct 1 ms 316 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 0 ms 208 KB Output is correct
27 Correct 0 ms 208 KB Output is correct
28 Correct 1 ms 208 KB Output is correct
29 Correct 0 ms 312 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 0 ms 320 KB Output is correct
35 Correct 0 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 0 ms 208 KB Output is correct
38 Correct 1 ms 208 KB Output is correct
39 Correct 54 ms 5372 KB Output is correct
40 Correct 87 ms 8612 KB Output is correct
41 Correct 40 ms 4424 KB Output is correct
42 Correct 46 ms 3968 KB Output is correct
43 Correct 27 ms 2884 KB Output is correct
44 Correct 106 ms 10816 KB Output is correct
45 Correct 103 ms 10960 KB Output is correct
46 Correct 106 ms 11076 KB Output is correct
47 Correct 96 ms 10976 KB Output is correct
48 Correct 100 ms 10952 KB Output is correct
49 Correct 419 ms 29452 KB Output is correct
50 Correct 391 ms 29512 KB Output is correct
51 Correct 395 ms 29416 KB Output is correct
52 Correct 396 ms 29456 KB Output is correct
53 Correct 370 ms 29492 KB Output is correct
54 Correct 399 ms 29324 KB Output is correct
55 Correct 950 ms 57920 KB Output is correct
56 Correct 940 ms 57880 KB Output is correct
57 Correct 916 ms 57916 KB Output is correct
58 Correct 928 ms 58044 KB Output is correct
59 Correct 906 ms 57920 KB Output is correct
60 Correct 882 ms 57936 KB Output is correct
61 Correct 929 ms 58016 KB Output is correct
62 Correct 929 ms 57904 KB Output is correct