#include <bits/stdc++.h>
#include "homecoming.h"
#define maxN 2000005
using namespace std;
int n,k,i,a[maxN],b[maxN],p[maxN],q[maxN];
long long dp[maxN],sb[maxN];
long long dp0(int n,int k,int a[],int b[]){
long long i,ans=0;
deque <long long> dq;
sb[n-1]=b[n-1];
for(i=n-2;i>=0;i--) sb[i]=sb[i+1]+b[i];
dp[n-1]=a[n-1]-b[n-1];
dq.push_back(n-1);
for(i=n-2;i>=0;i--){
long long x=dq.front();
dp[i]=a[i]+dp[x]-sb[i]+sb[x];
ans=max(ans,dp[i]);
if(dq.front()==i+k) dq.pop_front();
while(dq.size() && dp[dq.back()]+sb[dq.back()]<=dp[i]+sb[i]){
dq.pop_back();
}
dq.push_back(i);
}
return ans;
}
long long solve(int n,int k,int a[],int b[]){
long long ans=0,s;
int i,j;
for(j=0;j<k;j++){
s=0;
for(i=0;i<n;i++){
p[i]=a[(i+j)%n];
if(i>=k) q[i]=b[(i+j)%n];
else q[i]=0;
if(i<k) s+=b[(i+j)%n];
}
ans=max(ans,dp0(n,k,p,q)-s);
}
for(i=0;i<k;i++){
b[n-k+i]+=b[i];
}
for(i=k;i<n;i++){
p[i-k]=a[i];
q[i-k]=b[i];
}
ans=max(ans,dp0(n-k,k,p,q));
return ans;
}
int main()
{
return 0;
}
Compilation message
/tmp/cc3O3nAq.o: In function `main':
homecoming.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccXCg4c9.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status