이 제출은 이전 버전의 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 take = 0; take <= 1; take++ ) {
if ( !take ) {
dp[n][0] = 0;
for ( int j = 1; j <= k; j++ )
dp[n][j] = dp[n][j - 1] - b[j - 1];
} else {
for ( int j = 0; j <= k; j++ )
dp[n][0] = 0;
}
for ( int i = n - 1; i >= 0; i-- ) {
dp[i][0] = -INF;
if ( i >= k * take ) {
for ( int j = 0; j <= k; j++ )
dp[i][0] = max( dp[i][0], dp[i + 1][j] );
}
for ( int j = 1; j < k; j++ )
dp[i][j] = dp[i + 1][j - 1] - b[i];
dp[i][k] = max( dp[i + 1][k - 1], dp[i + 1][k] ) - b[i] + a[i];
}
//for ( int i = 0; i < n; i)
for ( int j = 0; j <= k; 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... |