이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "homecoming.h"
using namespace std;
long long solve(int n, int k, int *a, int *b){
int64_t ret = 0;
int64_t maxi, cur, cost, nextcost;
for(int it = 1; it <= 2; it++){
cost = accumulate(b, b + k, 0ll);
cur = a[0] - cost;
maxi = (it == 1 ? INT64_MIN : 0);
maxi = max(maxi, cur);
for(int i = 1; i < n; i++){
if(it == 2) nextcost = b[i + k - 1 - n];
else if(i + k - 1 < n) nextcost = b[i + k - 1];
else nextcost = 0;
cost -= b[i - 1];
cur = max(a[i] + cur - nextcost, a[i] - (cost + nextcost) + maxi);
cost += nextcost;
maxi = max(maxi, cur);
}
ret = max(maxi, ret);
}
return ret;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |