답안 #526100

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
526100 2022-02-13T17:35:49 Z TheKingAleks Money (IZhO17_money) C++14
100 / 100
971 ms 51524 KB
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 1e6+2;
int a[MAX_N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    multiset<int> s;
    s.insert(a[0]);
    for(int i=1; i<n; i++)
    {
        if(a[i] >= a[i-1])
        {
            s.insert(a[i]);
        }
        else break;
    }
    int idx = s.size();
    int ans = 1;
    while(idx < n)
    {
        vector<int> cur;
        set<int>::iterator first_lower_bound = s.lower_bound(a[idx]+1);
        cur.push_back(a[idx]);
        idx++;
        ans++;
        while(idx < n)
        {
            if(a[idx] < a[idx-1]) break;
            set<int>::iterator tmp;
            if(a[idx] == a[idx-1] && cur[0] == cur[cur.size()-1]) tmp = s.lower_bound(a[idx]+1);
            else tmp = s.lower_bound(a[idx]);
            if(tmp != first_lower_bound)
            {
                break;
            }
            cur.push_back(a[idx]);
            idx++;
        }
        for(auto x: cur) s.insert(x);
//        for(auto x: cur)
//        {
//            cout<<x<<" ";
//        }
//        cout<<endl;
    }
    cout<<ans<<endl;
}
/**
6
3 6 4 5 1 2
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 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 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 324 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 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 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 324 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 320 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 328 KB Output is correct
24 Correct 0 ms 324 KB Output is correct
25 Correct 0 ms 328 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 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 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 324 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 320 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 328 KB Output is correct
24 Correct 0 ms 324 KB Output is correct
25 Correct 0 ms 328 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 328 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 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 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 324 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 320 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 328 KB Output is correct
24 Correct 0 ms 324 KB Output is correct
25 Correct 0 ms 328 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 328 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 195 ms 24992 KB Output is correct
40 Correct 379 ms 40648 KB Output is correct
41 Correct 152 ms 20420 KB Output is correct
42 Correct 158 ms 17964 KB Output is correct
43 Correct 104 ms 12872 KB Output is correct
44 Correct 480 ms 51400 KB Output is correct
45 Correct 444 ms 51380 KB Output is correct
46 Correct 470 ms 51480 KB Output is correct
47 Correct 348 ms 51352 KB Output is correct
48 Correct 374 ms 51524 KB Output is correct
49 Correct 672 ms 51376 KB Output is correct
50 Correct 619 ms 51376 KB Output is correct
51 Correct 663 ms 51364 KB Output is correct
52 Correct 629 ms 51324 KB Output is correct
53 Correct 612 ms 51504 KB Output is correct
54 Correct 670 ms 51448 KB Output is correct
55 Correct 971 ms 51432 KB Output is correct
56 Correct 952 ms 51392 KB Output is correct
57 Correct 940 ms 51424 KB Output is correct
58 Correct 938 ms 51444 KB Output is correct
59 Correct 938 ms 51416 KB Output is correct
60 Correct 936 ms 51368 KB Output is correct
61 Correct 939 ms 51360 KB Output is correct
62 Correct 951 ms 51440 KB Output is correct