Submission #1125522

#TimeUsernameProblemLanguageResultExecution timeMemory
1125522zhasynMoney (IZhO17_money)C++20
0 / 100
1 ms324 KiB
#include <bits/stdc++.h> #define pb push_back #define pf push_front using namespace std; #define F first #define S second typedef long long ll; #define pii pair <int, int> #define pll pair <ll, ll> typedef long double ld; const ll N = 1e6 + 100, M = 500 + 10, len = 315, inf = 1e18; const ll mod = 998244353; ll um(ll a, ll b){ return (1LL * a * b) % mod; } ll subr(ll a, ll b){ return ((1LL * a - b) % mod + mod) % mod; } ll bp(ll x, ll step){ ll res = 1; while(step){ if(step & 1) res = um(res, x); x = um(x, x); step /= 2; } return res; } ll inv(ll x){ return bp(x, mod - 2); } int a[N], nt[N]; vector <pii> vec; bool was[N]; int main() { //ios_base::sync_with_stdio(false); //cin.tie(nullptr); //cout.tie(nullptr); int n, ans = 0; cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; vec.pb({a[i], i}); } sort(vec.begin(), vec.end()); for(auto u : vec){ if(was[u.S]) continue; ans++; int lim = nt[u.F]; for(int i = u.S; i <= n; i++){ if(was[i] == true) break; if(i > u.S){ if(a[i] < a[i - 1]) break; } if(lim != 0){ if(a[i] > lim) break; } was[i] = true; if(i > u.S && a[i - 1] != a[i]) nt[a[i - 1]] = a[i]; } } cout << ans; 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...