답안 #867997

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
867997 2023-10-30T06:46:32 Z 12345678 Money (IZhO17_money) C++17
100 / 100
862 ms 61956 KB
#include <bits/stdc++.h>

using namespace std;

const int inf=1e9, nx=1e6+5;
int n, v[nx], l, idx, dp[nx];
set<int> s;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    s.insert(1e9);
    for (int i=1; i<=n; i++)
    {
        cin>>v[i];
        //cout<<i<<' '<<v[i]<<' '<<l<<'\n';
        if (v[i]>=v[i-1]&&v[i]<=l) 
        {
            dp[i]=dp[idx]+1;
        }
        else
        {
            while (idx<i) s.insert(v[idx]), idx++;
            l=*s.upper_bound(v[i]);
            idx=i-1;
            dp[i]=dp[i-1]+1;
        }
        //cout<<"here"<<' '<<dp[i]<<'\n';
    }
    cout<<dp[n];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2524 KB Output is correct
8 Correct 1 ms 2408 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2524 KB Output is correct
8 Correct 1 ms 2408 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 0 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2524 KB Output is correct
8 Correct 1 ms 2408 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 0 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 0 ms 2512 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 0 ms 2396 KB Output is correct
33 Correct 0 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 0 ms 2392 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2392 KB Output is correct
38 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2524 KB Output is correct
8 Correct 1 ms 2408 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 0 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 0 ms 2512 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 0 ms 2396 KB Output is correct
33 Correct 0 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 0 ms 2392 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2392 KB Output is correct
38 Correct 1 ms 2392 KB Output is correct
39 Correct 45 ms 9712 KB Output is correct
40 Correct 95 ms 12640 KB Output is correct
41 Correct 36 ms 9300 KB Output is correct
42 Correct 38 ms 8924 KB Output is correct
43 Correct 28 ms 8276 KB Output is correct
44 Correct 101 ms 14808 KB Output is correct
45 Correct 97 ms 14932 KB Output is correct
46 Correct 99 ms 14944 KB Output is correct
47 Correct 78 ms 14964 KB Output is correct
48 Correct 86 ms 14864 KB Output is correct
49 Correct 339 ms 33364 KB Output is correct
50 Correct 320 ms 33592 KB Output is correct
51 Correct 321 ms 33272 KB Output is correct
52 Correct 318 ms 33360 KB Output is correct
53 Correct 342 ms 33536 KB Output is correct
54 Correct 320 ms 33364 KB Output is correct
55 Correct 791 ms 61952 KB Output is correct
56 Correct 838 ms 61808 KB Output is correct
57 Correct 857 ms 61768 KB Output is correct
58 Correct 828 ms 61780 KB Output is correct
59 Correct 862 ms 61956 KB Output is correct
60 Correct 830 ms 61780 KB Output is correct
61 Correct 818 ms 61776 KB Output is correct
62 Correct 835 ms 61904 KB Output is correct