Submission #962175

# Submission time Handle Problem Language Result Execution time Memory
962175 2024-04-13T08:26:58 Z Cookie Money (IZhO17_money) C++14
100 / 100
963 ms 58060 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define sz(a) (int)a.size()
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mpp make_pair
const ld PI = 3.14159265359, prec = 1e-9;;
//using u128 = __uint128_t;
//const int x[4] = {1, 0, -1, 0};
//const int y[4] = {0, -1, 0, 1};
const ll mod = 1e9 + 7, pr = 31;
const int mxn = 1e6 + 5, mxq = 1e5 + 5, sq = 450, mxv = 5e4 + 1;
//const int base = (1 <<18);
const ll inf = 1e9 + 5, neg = -69420, inf2 = 1e14;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
// have fun!
// <3;
int n;
int a[mxn + 1];
void solve(){
    cin >> n;
    for(int i = 1; i <= n; i++)cin >> a[i];
    set<int>s;
    int ans = 0;
    for(int i = 1; i <= n; ){
        auto it = s.upper_bound(a[i]);
        int lim;
        if(it == s.end())lim = inf;
        else lim = *it;
        int r = i + 1;
        while(r <= n && a[r] >= a[r - 1] && a[r] <= lim)r++;
        ans++;
        for(int j = i; j < r; j++)s.insert(a[j]);
        i = r;
    }
    cout << ans;
}
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("netw.inp", "r", stdin);
    //freopen("netw.out", "w", stdout)
    int tt; tt = 1;
    while(tt--){
        solve();
 
    }
    return(0);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 500 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 1 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 500 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 1 ms 472 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 500 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 472 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 500 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 1 ms 472 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 500 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 472 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 360 KB Output is correct
29 Correct 1 ms 360 KB Output is correct
30 Correct 0 ms 360 KB Output is correct
31 Correct 1 ms 480 KB Output is correct
32 Correct 1 ms 352 KB Output is correct
33 Correct 0 ms 616 KB Output is correct
34 Correct 1 ms 360 KB Output is correct
35 Correct 0 ms 360 KB Output is correct
36 Correct 1 ms 360 KB Output is correct
37 Correct 0 ms 360 KB Output is correct
38 Correct 1 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 500 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 1 ms 472 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 500 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 472 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 360 KB Output is correct
29 Correct 1 ms 360 KB Output is correct
30 Correct 0 ms 360 KB Output is correct
31 Correct 1 ms 480 KB Output is correct
32 Correct 1 ms 352 KB Output is correct
33 Correct 0 ms 616 KB Output is correct
34 Correct 1 ms 360 KB Output is correct
35 Correct 0 ms 360 KB Output is correct
36 Correct 1 ms 360 KB Output is correct
37 Correct 0 ms 360 KB Output is correct
38 Correct 1 ms 360 KB Output is correct
39 Correct 43 ms 5868 KB Output is correct
40 Correct 75 ms 8788 KB Output is correct
41 Correct 35 ms 5112 KB Output is correct
42 Correct 32 ms 4948 KB Output is correct
43 Correct 29 ms 4344 KB Output is correct
44 Correct 87 ms 10968 KB Output is correct
45 Correct 89 ms 10996 KB Output is correct
46 Correct 97 ms 11120 KB Output is correct
47 Correct 77 ms 10960 KB Output is correct
48 Correct 94 ms 11108 KB Output is correct
49 Correct 318 ms 29384 KB Output is correct
50 Correct 316 ms 29524 KB Output is correct
51 Correct 331 ms 29504 KB Output is correct
52 Correct 378 ms 29496 KB Output is correct
53 Correct 311 ms 29580 KB Output is correct
54 Correct 340 ms 29412 KB Output is correct
55 Correct 963 ms 57932 KB Output is correct
56 Correct 930 ms 58060 KB Output is correct
57 Correct 911 ms 57860 KB Output is correct
58 Correct 907 ms 58060 KB Output is correct
59 Correct 942 ms 57956 KB Output is correct
60 Correct 898 ms 58048 KB Output is correct
61 Correct 910 ms 57868 KB Output is correct
62 Correct 932 ms 57916 KB Output is correct