Submission #710129

#TimeUsernameProblemLanguageResultExecution timeMemory
710129arcaneMoney (IZhO17_money)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define mp make_pair #define pb emplace_back int32_t main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int ans = 0, n, x, prevx = -1; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; multiset <int> ms; set <int> s; bool flag = false; for (int i = 0; i < n; i++){ x = arr[i]; ms.insert(arr[i]); s.insert(arr[i]); if (!i){ ans += 1; flag = true; } else if (flag){ if (prevx > x){ ans += 1; flag = true; } else if (prevx < x){ auto it = s.find(prevx); it++; if (it != s.end() and *it <= x){ flag = false; } else ans += 1, flag = true; } } else{ if (prevx > x){ ans += 1; flag = true; } else if (prevx < x){ auto it = s.find(prevx); it++; if (it != s.end() and x <= *it and ms.count(prevx) == 1){ //cerr << prevx << ' ' << *it << ' ' << x << '\n'; flag = false; } else ans += 1, flag = true; } } //cerr << ans << '\n'; //cerr << ans << ' ' << *prev << ' ' << *cur << '\n'; prevx = x; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...