제출 #1128085

#제출 시각아이디문제언어결과실행 시간메모리
1128085baqqon_Money (IZhO17_money)C++20
0 / 100
1 ms360 KiB
/**
**/

#include <bits/stdc++.h>

using namespace std ;

#define ent '\n'
#define F first
#define S second
#define no "NO\n"
#define yes "YES\n"
#define pb push_back
#define pf push_front
#define sz(w) w.size()
#define int long long
#define all(w) w.begin() , w.end()
#define DH ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int mod = 1e9 + 6 , MOD = 1e9 + 7 , N = 1e6 + 11 , inf = 1e9 + 111 , INF = 1e18 , LG = 20 , M = 555 ;

/**
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap (a, b);
    }
    return a;
}
**/

/**
int binpow (int a, int n) {
    int res = 1;
    while (n) {
        if (n & 1)
            res *= a;
        a *= a;
        n >>= 1;
    }
    return res;
}
**/
void accepted() {
    int n , c = 0;
    cin >> n ;
    vector <int> a(n + 1) ;
    set <int> s ;
    for (int i = 1 ; i <= n ; i++) {
        cin >> a[i] ;
    }
    int j = 1 ;
    for (int i = 1 ; i < n ; i++)
    {
        j = i ;
        while(j < n && a[j] <= a[j + 1] && (s.upper_bound(a[j]) == s.end() || (*s.upper_bound(a[i]) >= a[j + 1]))) {
            j++;
        }
        c++;
        for (int k = i ; k <= j ; k++) {
            s.insert(a[k]) ;
        }
        i = j ;
    }
    cout << c ;
}
signed main()
{
    DH
    //freopen( "input.in" , "r" , stdin ) ;
    //freopen( "output.out" , "w" , stdout ) ;
    int T = 1 ;
    //cin >> T ;
    while( T -- )
    {
        accepted() ;
        cout << ent ;
    }
}

/**
**/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...