Submission #488336

# Submission time Handle Problem Language Result Execution time Memory
488336 2021-11-18T15:33:13 Z OttincaM Money (IZhO17_money) C++14
100 / 100
931 ms 61932 KB
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <climits>
#include <queue>
#include <fstream>
 
using namespace std;

#define all(x) (x).begin(), (x).end()
#define int long long
#define ll long long
#define ff first
#define ss second
#define MP make_pair
#define pb push_back
#define pf push_front
#define db double
 
ll gcd(ll a,ll b){
    return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a,ll b){
    return a / gcd(a, b) * b;
}

ll binary_power(ll a,ll n){
    ll res = 1;
    while(n){
        if(n & 1)   -- n, res = res * a;
        else a = a * a, n >>= 1;
    }
    return res;
}

ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; ++i)
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    if (n > 1)
        result -= result / n;
    return result;
}
/*<______________________________________________>*/
#define itn int
const int MOD = 1e9 + 7;
const int INF = 1000000101;
const long long LLINF = 1223372000000000555;

const int M = 1030;
const int maxn = 1e6 + 9;
int a[maxn];
int n;
void t_main(){
    cin >> n;
    for(itn i = 0; i < n; i ++){
        cin >> a[i];
    }
    set<int> st;
    st.insert(INF);
    int ans = 0;
    for(int i = 0; i < n; i ++) {
        int j = i;
        int nxt = *st.lower_bound(a[j] + 1);
        st.insert(a[j]);
        while(j + 1 < n && a[j] <= a[j + 1] && a[j + 1] <= nxt) 
            st.insert(a[++j]);    
        i = j;
        ans ++;
    }
    cout << ans;
}
 
 
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while(tt --) t_main();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 0 ms 208 KB Output is correct
20 Correct 0 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 0 ms 208 KB Output is correct
24 Correct 0 ms 208 KB Output is correct
25 Correct 0 ms 320 KB Output is correct
26 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 0 ms 208 KB Output is correct
20 Correct 0 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 0 ms 208 KB Output is correct
24 Correct 0 ms 208 KB Output is correct
25 Correct 0 ms 320 KB Output is correct
26 Correct 0 ms 208 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 0 ms 208 KB Output is correct
29 Correct 1 ms 208 KB Output is correct
30 Correct 0 ms 208 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
33 Correct 0 ms 208 KB Output is correct
34 Correct 0 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 0 ms 208 KB Output is correct
37 Correct 0 ms 324 KB Output is correct
38 Correct 0 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 0 ms 208 KB Output is correct
20 Correct 0 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 0 ms 208 KB Output is correct
24 Correct 0 ms 208 KB Output is correct
25 Correct 0 ms 320 KB Output is correct
26 Correct 0 ms 208 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 0 ms 208 KB Output is correct
29 Correct 1 ms 208 KB Output is correct
30 Correct 0 ms 208 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
33 Correct 0 ms 208 KB Output is correct
34 Correct 0 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 0 ms 208 KB Output is correct
37 Correct 0 ms 324 KB Output is correct
38 Correct 0 ms 336 KB Output is correct
39 Correct 49 ms 7200 KB Output is correct
40 Correct 87 ms 11812 KB Output is correct
41 Correct 39 ms 5928 KB Output is correct
42 Correct 38 ms 5304 KB Output is correct
43 Correct 25 ms 3804 KB Output is correct
44 Correct 102 ms 14828 KB Output is correct
45 Correct 100 ms 14700 KB Output is correct
46 Correct 105 ms 14952 KB Output is correct
47 Correct 90 ms 14940 KB Output is correct
48 Correct 90 ms 14948 KB Output is correct
49 Correct 369 ms 33400 KB Output is correct
50 Correct 360 ms 33312 KB Output is correct
51 Correct 374 ms 33364 KB Output is correct
52 Correct 356 ms 33332 KB Output is correct
53 Correct 363 ms 33400 KB Output is correct
54 Correct 365 ms 33156 KB Output is correct
55 Correct 891 ms 61892 KB Output is correct
56 Correct 842 ms 61896 KB Output is correct
57 Correct 931 ms 61932 KB Output is correct
58 Correct 870 ms 61848 KB Output is correct
59 Correct 820 ms 61752 KB Output is correct
60 Correct 878 ms 61732 KB Output is correct
61 Correct 861 ms 61728 KB Output is correct
62 Correct 863 ms 61768 KB Output is correct