제출 #1128252

#제출 시각아이디문제언어결과실행 시간메모리
1128252baqqon_Money (IZhO17_money)C++20
100 / 100
848 ms55224 KiB
/** Baktiyar™ Soon..... **/ #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; } **/ void accepted() { int n , c = 0 , l = 1; cin >> n; vector<int> a(n + 1) ; multiset<int> s ; for (int i = 1; i <= n; i++) { cin >> a[i] ; } for (int i = 2; i <= n; i++) { if (a[i] < a[i - 1]) { for (int j = l; j < i; j++) { s.insert(a[j]); } c++ ; l = i ; continue ; } auto up = s.upper_bound(a[l]) ; if (up != s.end() && a[i] > *up) { for (int j = l; j < i; j++) { s.insert(a[j]) ; } c++ ; l = i ; } } cout << c + 1 ; } signed main() { DH //freopen( "input.in" , "r" , stdin ) ; //freopen( "output.out" , "w" , stdout ) ; int T = 1 ; //cin >> T ; while( T -- ) { accepted() ; cout << ent ; } } /** I❤️U **/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...