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>
#include "homecoming.h"
using namespace std;
const long long INF = 1e16;
const int MAX_N = 5000;
long long dp[MAX_N + 1][MAX_N + 1];
long long solve( int n, int k, int a[], int b[] ) {
long long ans = 0;
for ( int l = 0; l <= k; l++ ) {
dp[n][n] = 0;
for ( int i = n - 1; i >= 0; i-- ) {
dp[i][i] = -INF;
if ( i >= l ) {
for ( int j = i + 1; j <= n + l; j++ )
dp[i][i] = max( dp[i][i], dp[i + 1][j] );
}
for ( int j = i + 1; j <= n + l; j++ )
dp[i][j] = dp[i + 1][j] - b[i] + (j - i >= k ? a[i] : 0);
}
for ( int j = 0; j <= n + l; j++ )
ans = max( ans, dp[0][j] );
}
return ans;
}
# | 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... |