제출 #488336

#제출 시각아이디문제언어결과실행 시간메모리
488336OttincaMMoney (IZhO17_money)C++14
100 / 100
931 ms61932 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...