Submission #386213

# Submission time Handle Problem Language Result Execution time Memory
386213 2021-04-06T05:53:58 Z kingline Money (IZhO17_money) C++17
100 / 100
1271 ms 62092 KB
/*#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")*/
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <queue>
#define pb push_back
#define F first
#define mp make_pair
#define S second
#define pii pair <int, int >
#define pll pair <long long, long long >
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(data) data.begin() , data.end()
#define endl '\n'
#define bo cout << "OK" << endl;
#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
//freopen("nenokku_easy.in", "r", stdin);
//freopen("nenokku_easy.out", "w", stdout);
#define int long long

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const ll N = 1e6 + 1;
const ll mod = 1e9 + 7;
const ll INF = 1e10;
const ll M = (1 << 17) + 1;
const ll LL = 1;
const ll p = 31;
bool ok;

int gcd (int a, int b) {
	if (b == 0)
		return a;
	else
		return gcd (b, a % b);
}

ll bp (int a, int b) {
    if(b == 0) return 1;
    else if(b % 2) return ((bp(a, b - 1) % mod) * a) % mod;
    else {
        int c = bp(a, b / 2) % mod;
        return (c * c) % mod;
    }
}

ll sum(int x) {
    int res = 0;
    while(x) {
        res += x % 10;
        x /= 10;
    }
    return res;
}

ll q, n, m, k, a[N], pref[N], b[N];
string s, s1, s2;

void solve() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    multiset < int > st;
    st.insert(1e7);
    st.insert(-1);
    int ans = 0;
    a[0] = -1; a[n + 1] = 1e7;
    for(int i = 1; i <= n; i++) {
        multiset < int >::iterator itt = st.upper_bound(a[i]);
        st.insert(a[i]);
        //cout << a[i] << " ";
        while(a[i] <= a[i + 1] && a[i + 1] <= *itt && i + 1 <= n) {
            ++i;
            st.insert(a[i]);
            //cout << a[i] << " ";
        }
        //cout << endl;
        ++ans;
    }
    cout << ans;
}

main()
{
    //file("B");
    ios;
    q = 1;
    //cin >> q;
    while(q--) {
        solve();
    }
}








Compilation message

money.cpp:99:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   99 | main()
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 236 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 236 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 2 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 492 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
38 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 236 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 2 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 492 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
38 Correct 1 ms 364 KB Output is correct
39 Correct 200 ms 29952 KB Output is correct
40 Correct 397 ms 48888 KB Output is correct
41 Correct 145 ms 24300 KB Output is correct
42 Correct 175 ms 21484 KB Output is correct
43 Correct 128 ms 15232 KB Output is correct
44 Correct 484 ms 61984 KB Output is correct
45 Correct 448 ms 61804 KB Output is correct
46 Correct 476 ms 62060 KB Output is correct
47 Correct 309 ms 62076 KB Output is correct
48 Correct 343 ms 62032 KB Output is correct
49 Correct 804 ms 61968 KB Output is correct
50 Correct 764 ms 61932 KB Output is correct
51 Correct 831 ms 62092 KB Output is correct
52 Correct 781 ms 61932 KB Output is correct
53 Correct 778 ms 62060 KB Output is correct
54 Correct 774 ms 61932 KB Output is correct
55 Correct 1209 ms 61832 KB Output is correct
56 Correct 1267 ms 62060 KB Output is correct
57 Correct 1271 ms 61804 KB Output is correct
58 Correct 1241 ms 61972 KB Output is correct
59 Correct 1188 ms 61804 KB Output is correct
60 Correct 1226 ms 61952 KB Output is correct
61 Correct 1247 ms 61932 KB Output is correct
62 Correct 1248 ms 61932 KB Output is correct