Submission #958716

# Submission time Handle Problem Language Result Execution time Memory
958716 2024-04-06T12:49:46 Z aeg Homecoming (BOI18_homecoming) C++17
0 / 100
20 ms 4200 KB
#include <bits/stdc++.h>
#include "homecoming.h"

using namespace std;

long long solve(int n, int k, int *a, int *b){
	long long cur, cost, nextcost, maxi = INT_MIN;
	cost = accumulate(b, b + k, 0ll);
	maxi = cur = a[0] - cost;
	for(int i = 1; i < n; i++){
		cost -= b[i - 1];
		if(i + k - 1 < n) nextcost = b[k + i - 1];
		else nextcost = 0;
		cur = max(cur + a[i] - nextcost, maxi + a[i] - (cost + nextcost));
		maxi = max(maxi, cur);
		cost += nextcost;
	}
	cost = accumulate(b, b + k, 0ll);
	maxi = max(0ll, a[0] - cost);
	cur = a[0] - cost;
	for(int i = 1; i < n; i++){
		cost -= b[i - 1];
		if(i + k - 1 < n) nextcost = b[k + i - 1];
		else nextcost = b[k + i - 1 - n];
		cur = max(cur + a[i] - nextcost, maxi + a[i] - (cost + nextcost));
		maxi = max(maxi, cur);
		cost += nextcost;
	}
	return maxi;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 4200 KB Output is correct
2 Incorrect 2 ms 860 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -