답안 #958714

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
958714 2024-04-06T12:42:41 Z aeg Homecoming (BOI18_homecoming) C++14
0 / 100
29 ms 17792 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 17792 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -