답안 #497118

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
497118 2021-12-22T12:59:56 Z Shavkatjon Money (IZhO17_money) C++14
0 / 100
1 ms 204 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 + 1);
    set<int> s;
    s.insert(INT_MAX);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    a[n] = 0;
    int i = 0;
    while (i < n)
    {
        s.insert(a[i]);
        int up = *s.upper_bound(a[i]);
        int j = i + 1;
        while(a[j - 1] < a[j] && a[j] < up){
            s.insert(a[j]);
            j++;
        }
        ans++;
        i = j;
    }
    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 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -