제출 #578772

#제출 시각아이디문제언어결과실행 시간메모리
578772AlperenTHomecoming (BOI18_homecoming)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "homecoming.h" using namespace std; const long long INF = 1e18; long long solve(int n, int k, int *a, int *b){ long long ans = 0; long long mx, cur, cost; for(int it = 1; it <= 2; it++){ mx = (it == 1 ? -INF : 0); cost = accumulate(b, b + k, 0ll); cur = a[0] - cost; mx = max(mx, cur); for(int i = 1; i < n; i++){ cost -= b[i - 1]; if(i + k - 1 < n) nxtcost = b[i + k - 1]; else if(it == 2) nxtcost = b[i + k - 1 - n]; else nxtcost = 0; cur = max(a[i] + cur - nxtcost, a[i] - (cost + nxtcost) + mx); cost += nxtcost; mx = max(mx, cur); } ans = max(ans, mx); } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

homecoming.cpp: In function 'long long int solve(int, int, int*, int*)':
homecoming.cpp:25:22: error: 'nxtcost' was not declared in this scope; did you mean 'cost'?
   25 |    if(i + k - 1 < n) nxtcost = b[i + k - 1];
      |                      ^~~~~~~
      |                      cost
homecoming.cpp:26:21: error: 'nxtcost' was not declared in this scope; did you mean 'cost'?
   26 |    else if(it == 2) nxtcost = b[i + k - 1 - n];
      |                     ^~~~~~~
      |                     cost
homecoming.cpp:27:9: error: 'nxtcost' was not declared in this scope; did you mean 'cost'?
   27 |    else nxtcost = 0;
      |         ^~~~~~~
      |         cost
homecoming.cpp:29:27: error: 'nxtcost' was not declared in this scope; did you mean 'cost'?
   29 |    cur = max(a[i] + cur - nxtcost, a[i] - (cost + nxtcost) + mx);
      |                           ^~~~~~~
      |                           cost