Submission #852935

# Submission time Handle Problem Language Result Execution time Memory
852935 2023-09-23T08:22:06 Z Abito Homecoming (BOI18_homecoming) C++17
0 / 100
120 ms 41584 KB
#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=1e4+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]);
            ans=max(ans,dp[l][r]);
        }
    }return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 120 ms 41584 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 120 ms 41584 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 35 ms 8796 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 120 ms 41584 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -