제출 #531242

#제출 시각아이디문제언어결과실행 시간메모리
531242penguin133Financial Report (JOI21_financial)C++14
14 / 100
4082 ms56316 KiB
#include <bits/stdc++.h> using namespace std; int A[500005], dp[300005]; map<pair<int, int> , int> m; int n,d; int c(int i, int mx){ if(i >= n)return 0; if(m[{i,mx}])return m[{i,mx}]; int ans = 0; for(int j=i+1;j<=min(i+d, n);j++){ ans = max(ans, c(j, max(mx,A[j])) + (A[j]>mx?1:0)); } //cout << i << " " << mx << " " << ans << '\n'; if(mx == -1)ans = max(ans, c(i+1, -1)); return m[{i,mx}] = ans; } int main(){ cin >> n >> d; for(int i=1;i<=n;i++)cin >> A[i]; cout << c(0, -1) << '\n'; }
#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...