답안 #497487

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
497487 2021-12-23T06:48:51 Z Shavkatjon Money (IZhO17_money) C++14
100 / 100
917 ms 62008 KB
#include <bits/stdc++.h>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define int long long
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int gcd(int a, int b) {
    return b ? gcd (b, a % b) : a;
}

string reverse(string s){
    int n = s.length();
    for (int i = 0; i < (n+1) / 2; i++) swap(s[i], s[n - i - 1]);
    return s;
}


int binpow (int a, int n) {
    if (n == 0)
        return 1LL;
    if (n % 2 == 1)
        return ((binpow (a, n-1)%MOD) * 1LL * a)%MOD;
    else {
        int b = binpow (a, n/2)%MOD;
        return (b * b)%MOD;
    }
}

//void swap(int &a, int &b){
//    b = (a+b) - (a=b);
//}

void solve(){
    int n, ans = 0;
    cin >> n;
    vi a(n);
    set<int> s;
    s.insert(INT_MAX);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; )
    {
        s.insert(a[i]);
        int up = *s.upper_bound(a[i]);
        i++;
        while(a[i] >= a[i - 1] && a[i] <= up) s.insert(a[i++]);
        ans++;
    }
    cout << ans;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
        cout << "\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 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 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 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 316 KB Output is correct
15 Correct 0 ms 312 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 0 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 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 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 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 316 KB Output is correct
15 Correct 0 ms 312 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 308 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 312 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 312 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 0 ms 204 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 0 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 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 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 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 316 KB Output is correct
15 Correct 0 ms 312 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 308 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 312 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 312 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 312 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 0 ms 316 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 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 0 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 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 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 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 316 KB Output is correct
15 Correct 0 ms 312 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 308 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 312 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 312 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 312 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 0 ms 316 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 50 ms 7244 KB Output is correct
40 Correct 89 ms 11712 KB Output is correct
41 Correct 39 ms 5900 KB Output is correct
42 Correct 38 ms 5284 KB Output is correct
43 Correct 31 ms 3848 KB Output is correct
44 Correct 117 ms 14776 KB Output is correct
45 Correct 111 ms 14776 KB Output is correct
46 Correct 105 ms 14916 KB Output is correct
47 Correct 88 ms 14916 KB Output is correct
48 Correct 93 ms 14916 KB Output is correct
49 Correct 396 ms 33376 KB Output is correct
50 Correct 418 ms 33468 KB Output is correct
51 Correct 383 ms 33348 KB Output is correct
52 Correct 371 ms 33296 KB Output is correct
53 Correct 372 ms 33320 KB Output is correct
54 Correct 373 ms 33284 KB Output is correct
55 Correct 888 ms 61872 KB Output is correct
56 Correct 908 ms 61772 KB Output is correct
57 Correct 897 ms 61812 KB Output is correct
58 Correct 891 ms 61892 KB Output is correct
59 Correct 917 ms 61856 KB Output is correct
60 Correct 911 ms 61896 KB Output is correct
61 Correct 889 ms 61828 KB Output is correct
62 Correct 883 ms 62008 KB Output is correct