이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "homecoming.h"
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define y1 YONE
typedef unsigned long long ull;
using namespace std;
const int NN=1e3+5;
int a[NN],b[NN],n,k,dp[NN][NN],pa[NN],pb[NN];
long long solve(int32_t N, int32_t K, int32_t *A, int32_t *B){
n=N,k=K;
for (int i=1;i<=n;i++) a[i]=A[i-1],pa[i]=pa[i-1]+a[i];
for (int i=1;i<=n;i++) b[i]=B[i-1],pb[i]=pb[i-1]+b[i];
for (int i=n+1;i<=n+k-1;i++) b[i]=b[i-n],pb[i]=pb[i-1]+b[i];
int ans=0;
for (int len=1;len<=n+k-1;len++){
for (int l=1;l<=n;l++){
int r=l+len-1;
if (r>n+k-1) break;
dp[l][r]=-pb[min(r,l+n-1)]+pb[l-1];
if (min(r-k+1,l+n-1)>=l) dp[l][r]+=pa[min(r-k+1,l+n-1)]-pa[l-1];
for (int i=l;i<r;i++) dp[l][r]=max(dp[l][r],dp[l][i]+dp[i+1][r]);
dp[l][r]=max(dp[l][r],0LL);
ans=max(ans,dp[l][r]);
}
}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... |