Submission #546424

#TimeUsernameProblemLanguageResultExecution timeMemory
546424syrtinMoney (IZhO17_money)C++17
100 / 100
1214 ms54096 KiB
#include <bits/stdc++.h> #define ss second #define ff first #define pb push_back #define all(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int N = 1e5 + 123; const int mod = 998244353; const int inf = 1e9; void solve() { int n; cin >> n; int a, ans = 1, x = -1; set<int> s; auto y = s.end(); while(n) { cin >> a; if(a >= x) { x = a; s.insert(x); } else { ans++; //cout << n << "|"; x = a; y = s.upper_bound(x); s.insert(x); n--; break; } n--; } while(n) { cin >> a; if(a < x || (y != s.end() && *y < a)){ ans++; y = s.upper_bound(a); //cout << n << "|"; } s.insert(a); x = a; n--; } cout << ans; } int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(0); int t = 1; //cin >> t; while(t--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...