Submission #578771

# Submission time Handle Problem Language Result Execution time Memory
578771 2022-06-17T23:01:56 Z AlperenT Homecoming (BOI18_homecoming) C++17
0 / 100
28 ms 5456 KB
#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, nxtcost = 0;

	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];

			cur = max(a[i] + cur - nxtcost, a[i] - (cost + nxtcost) + mx);

			cost += nxtcost;

			mx = max(mx, cur);
		}

		ans = max(ans, mx);
	}

	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 5456 KB Output is correct
2 Incorrect 2 ms 852 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -