답안 #1067422

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067422 2024-08-20T16:48:57 Z vjudge1 Money (IZhO17_money) C++17
100 / 100
679 ms 58960 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
const int maxN=1e6+5;
const ll inf=2e18;
int n,a[maxN+1],pre[maxN+1];
set<ll> se;
int main()
{
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        pre[i]=-1;
    }
    int pos=-1;
    se.insert(inf);
    se.insert(a[1]);
    for(int i=2;i<=n;i++)
    {
        if(a[i]<a[i-1])
        {
            pos=i;
            break;
        }
        else se.insert(a[i]);
    }
    int cnt=1;
    if(pos==-1)
    {
        cout<<cnt;
        return 0;
    }
    cnt++;
    auto itr=se.upper_bound(a[pos]);
    int i=pos+1;
    ll base=(*itr);
    se.insert(a[pos]);
    while(i<=n)
    {
        while(i<=n&&a[i]>=a[i-1]&&(*se.lower_bound(a[i]))<=base)
        {
            se.insert(a[i]);
            i++;
        }
        //cout<<i<<" "<<cnt<<" "<<base<<'\n';
        if(i<=n)
        {
            cnt++;
            base=(*se.upper_bound(a[i]));
            se.insert(a[i]);
            //cout<<i<<" "<<(*se.upper_bound(a[i]))<<'\n';
            i++;
        }
    }
    cout<<cnt;
}
/*20
324662 468027 324662 324662 468027 324662 468027 324662 324662 468027 963343 944165 165047 127072 405908 918630 854332 571550 909067 448963*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 464 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 2392 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 464 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 464 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 2392 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 464 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 436 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 468 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 464 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 2392 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 464 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 436 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 468 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 464 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 2392 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 464 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 436 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 468 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 39 ms 5764 KB Output is correct
40 Correct 66 ms 10244 KB Output is correct
41 Correct 30 ms 4848 KB Output is correct
42 Correct 29 ms 4640 KB Output is correct
43 Correct 21 ms 3164 KB Output is correct
44 Correct 87 ms 12116 KB Output is correct
45 Correct 84 ms 11788 KB Output is correct
46 Correct 81 ms 11852 KB Output is correct
47 Correct 74 ms 11860 KB Output is correct
48 Correct 70 ms 11740 KB Output is correct
49 Correct 308 ms 30084 KB Output is correct
50 Correct 282 ms 30288 KB Output is correct
51 Correct 284 ms 30280 KB Output is correct
52 Correct 274 ms 30088 KB Output is correct
53 Correct 271 ms 30292 KB Output is correct
54 Correct 265 ms 30188 KB Output is correct
55 Correct 647 ms 58588 KB Output is correct
56 Correct 633 ms 58624 KB Output is correct
57 Correct 629 ms 58960 KB Output is correct
58 Correct 620 ms 58704 KB Output is correct
59 Correct 603 ms 58784 KB Output is correct
60 Correct 679 ms 58708 KB Output is correct
61 Correct 635 ms 58764 KB Output is correct
62 Correct 679 ms 58708 KB Output is correct