답안 #861658

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861658 2023-10-16T15:46:17 Z Aiperiii Homecoming (BOI18_homecoming) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "homecoming.h"
using namespace std;

#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
const int N=2e6+6;
int dp[N][2];
int solve(int n,int k,int a[],int b[]){
    vector <int> pr;
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=b[i];
        pr.push_back(sum);
    }
    dp[0][0]=-1e18;
    dp[0][1]=a[0]-pr[k-1];
    for(int i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][0],dp[i-1][1]);
        int val1=dp[i-1][1]+a[i];
        if(i+k-1<n){
            val1-=b[i+k-1];
        }
        int val2=dp[i-1][0]+a[i]-pr[min(i+k-1,n-1)]+pr[i-1];
        dp[i][1]=max(val1,val2);
    }
    int res1=max(dp[n-1][0],dp[n-1][1]);
    dp[0][0]=0;
    dp[0][1]=-1e18;
    for(int i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][0],dp[i-1][1]);
        int val1=dp[i-1][1]+a[i]-b[(i+k-1)%n];
        int val2=dp[i-1][0]+a[i]-pr[min(i+k-1,n-1)]+pr[i-1];
        if(i+k-1>n-1){
            val2-=pr[i+k-1-n];
        }
        dp[i][1]=max(val1,val2);
    }
    int res2=max(dp[n-1][0],dp[n-1][1]);
    return max(res1,res2);
}

Compilation message

/usr/bin/ld: /tmp/ccxtdYdi.o: in function `main':
grader.cpp:(.text.startup+0xdf): undefined reference to `solve(int, int, int*, int*)'
collect2: error: ld returned 1 exit status