답안 #646807

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
646807 2022-09-30T17:59:12 Z jasmin Homecoming (BOI18_homecoming) C++14
컴파일 오류
0 ms 0 KB
#include<homecoming.h>
#include<bits/stdc++.h>
using namespace std;

const long long inf=1e18;

long long solve(int n, int k, vector<int>& a, vector<int>& b){
    for(int i=0; i<n; i++){
        b.push_back(b[i]);
    }
    vector<int> prefixsum(n*2+1, 0);
    for(int i=1; i<=n*2; i++){
        prefixsum[i]=prefixsum[i-1]+b[i-1];
    }

    vector<long long> dp(n+1, -inf);
    long long ans=0;
    dp[0]=0;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=k; j++){
            if(i-j<0) continue;

            int cost=prefixsum[i+k-2]-prefixsum[i-j+k-2];
            dp[i]=max(dp[i], dp[i-j]+a[i-1]-cost);
            ans=max(ans, dp[i]);
        }
    }
    return ans;
}

/*signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> b(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    cout << solve(n, k, a, b) << "\n";
}*/

Compilation message

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