Submission #971229

#TimeUsernameProblemLanguageResultExecution timeMemory
971229devariaotaMoney (IZhO17_money)C++17
100 / 100
1076 ms58132 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; #pragma GCC optimize("Ofast") #define vi vector<int> #define vll vector<ll> #define pii pair<int, int> #define mp make_pair #define pb push_back #define lb lower_bound #define ub upper_bound #define fi first #define sc second #define endl '\n' #define gl ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int main() { int n, id = 1, ans = 1, akhir = INT_MAX; cin >> n; vi a(n); set<int> st; for(int i = 0; i < n; i++) cin >> a[i]; st.insert(a[0]); while(a[id] >= a[id - 1] and id < n){ st.insert(a[id]); id++; } while(id < n){ if(a[id] < a[id - 1] or a[id] > akhir){ ans++; auto it = st.ub(a[id]); if(it != st.end()) akhir = *it; else akhir = INT_MAX; } st.insert(a[id]); id++; } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...