Submission #1097225

#TimeUsernameProblemLanguageResultExecution timeMemory
1097225alexddHomecoming (BOI18_homecoming)C++17
0 / 100
40 ms52924 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...