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 <iostream>
#include <cstring>
using namespace std;
int n, d, a[405], dp[405][405][405];
int brutus(int i, int j, int k) {
if (i > n) return (j == n ? 0 : -500);
if (dp[i][j][k] != -1000) return dp[i][j][k];
if (j != 0 and i - j > d) dp[i][j][k] = -500;
else dp[i][j][k] = max(brutus(i + 1, j, k), (a[i] > a[k]) + brutus(i + 1, i, (a[i] > a[k] ? i : k)));
return dp[i][j][k];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> d;
a[0] = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 0; i < 405; i++) {
for (int j = 0; j < 405; j++) {
for (int k = 0; k < 405; k++) {
dp[i][j][k] = -1000;
}
}
}
if (n > 400) cout << "parina eishob" << '\n';
else cout << brutus(1, 0, 0) << '\n';
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... |