Submission #1097225

# Submission time Handle Problem Language Result Execution time Memory
1097225 2024-10-06T13:50:44 Z alexdd Homecoming (BOI18_homecoming) C++17
0 / 100
40 ms 52924 KB
#include <bits/stdc++.h>
#include "homecoming.h"
using namespace std;
const long long INF = 1e18;
long long dp[6000005][2];
long long a[6000005],b[6000005];
long long prefa[6000005],prefb[6000005];
long long int solve(int N, int K, int *copA, int *copB)
{
    for(int i=0;i<N;i++)
    {
        a[i+K] = a[i+N+K] = copA[i];
        b[i+1] = b[i+N+1] = copB[i];
    }
    for(int i=1;i<=2*N;i++)
    {
        prefa[i] = prefa[i-1] + a[i];
        prefb[i] = prefb[i-1] + b[i];
    }
    for(int i=0;i<K;i++)
    {
        dp[i][0]=0;
        dp[i][1]=-INF;
    }
    for(int i=K;i<N+K;i++)
    {
        dp[i][0] = max(dp[i-1][0], dp[i-1][1]);
        dp[i][1] = -INF;
        dp[i][1] = max(dp[i][1], dp[i-1][1]+a[i]-b[i]);
        dp[i][1] = max(dp[i][1], dp[i-K][0]+a[i]-(prefb[i]-prefb[i-K]));
        //cout<<i<<"  "<<dp[i][0]<<" "<<dp[i][1]<<" dp\n";
    }
    return max(dp[N+K-1][0], dp[N+K-1][1]);
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 40 ms 52924 KB Output is correct
2 Incorrect 2 ms 1112 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -