이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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++ ) {
for ( int j = n; j <= n + l; j++ )
dp[n][j] = -INF;
dp[n][n + l] = 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... |