Submission #768868

#TimeUsernameProblemLanguageResultExecution timeMemory
768868divadFinancial Report (JOI21_financial)C++14
0 / 100
111 ms2676 KiB
#include <bits/stdc++.h> using namespace std; const int NMAX = 3e5+2; int n,d,a[NMAX],aib[NMAX],dp[NMAX]; map<int, int> mp; void update(int pos, int val){ for(int i = pos; i < NMAX; i += (i&-i)){ aib[i] = max(aib[i], val); } } int query(int pos){ int ans = 0; for(int i = pos; i > 0; i -= (i&-i)){ ans = max(ans, aib[i]); } return ans; } int main() { cin >> n >> d; for(int i = 1; i <= n; i++){ cin >> a[i]; mp[a[i]] = i; } int cnt = 0; for(auto &it: mp){ it.second = ++cnt; } for(int i = 1; i <= n; i++){ a[i] = mp[a[i]]; } for(int i = 1; i <= n; i++){ dp[i] = max(dp[i], 1+query(a[i]-1)); update(a[i], dp[i]); } cout << dp[n]; 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...