Submission #499582

#TimeUsernameProblemLanguageResultExecution timeMemory
499582gromperenFinancial Report (JOI21_financial)C++14
14 / 100
4078 ms4940 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int INF = 3e5+5; int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, d; cin >> n >> d; vector<int> a(n), b(n), r(n); map<int,int> compress; vector<int> dp(n+1, 1); for (int i = 0; i < n; ++i) { cin >> a[i]; b[i] = a[i]; } sort(b.begin(), b.end()); for (int i =0; i < n; ++i) { if (!compress[b[i]]) { compress[b[i]] = compress.size(); } } for (int i = 0; i < n; ++i) { a[i] = compress[a[i]]; } for (int i = 0; i < n; ++i) { int cnt = 0; for (int j = i + 1; j < n; ++j) { if (a[j] <= a[i]) cnt = 0; else { cnt++; if (cnt == d+1) { r[i] = j; break; } } } if (cnt <= d) r[i] = n; //cout << r[i] << " "; } //cout << endl; int ans = 0; for (int i = 0; i < n; ++i) { for (int j = i + 1; j < r[i]; ++j) { if (a[i] < a[j]) { dp[j] = max(dp[j], dp[i] + 1); } } ans = max(ans, dp[i]); //cout << dp[i] << " "; } cout << ans << "\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...