Submission #1038234

#TimeUsernameProblemLanguageResultExecution timeMemory
1038234LOLOLOMoney (IZhO17_money)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> typedef long long ll; #define f first #define s second #define pb push_back #define ep emplace #define eb emplace_back #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define uniquev(v) sort(all(v)), (v).resize(unique(all(v)) - (v).begin()) #define mem(f,x) memset(f , x , sizeof(f)) #define sz(x) (int)(x).size() #define __lcm(a, b) (1ll * ((a) / __gcd((a), (b))) * (b)) #define mxx *max_element #define mnn *min_element #define cntbit(x) __builtin_popcountll(x) using namespace std; const int N = 1e6 + 10; int a[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("SWOOD.INP", "r", stdin); //freopen("SWOOD.OUT", "w", stdout); int n; cin >> n; set <int> st; st.insert(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } int cnt = 0; for (int i = 1; i <= n; i++) { int lim = *st.upper_bound(a[i]); st.insert(a[i]); cnt++; int j = i; while (j + 1 <= n && a[j + 1] >= a[j] && a[j + 1] <= lim) { j++; st.insert(a[j]); } i = j; } cout << cnt << '\n'; return 0; } /* 4 3 2 3 2 6 2 2 4 2 6 5 1 1 2 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...