This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int MX = 405;
int dp[MX][MX][MX];
int n, D;
int a[MX];
int solve(int i, int can, int bigID) {
if(i==n) {
return (a[i]>a[bigID]);
}
int &ret = dp[i][can][bigID];
if(ret!=-1) return ret;
ret = 0;
ret = solve(i+1, D-1, (a[i]>a[bigID]?i:bigID)) + (a[i]>a[bigID]);
if(can) {
ret = max(ret, solve(i+1, can-1, bigID));
}
return ret;
}
void PlayGround() {
cin>>n>>D;
a[0] = -1;
for(int i=1; i<=n; ++i) {
cin>>a[i];
}
memset(dp, -1, sizeof dp);
cout<<solve(1, n, 0)<<'\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |