87472024-01-28 17:24:36IgnácVásárlás (75 pont)pypy3Runtime error 0/7575ms90724 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int sum = 0, sum2 = 0, min1 = INT_MAX, max2 = INT_MIN, min1i = 0, max2i = 0, max2min1i = 0;
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		sum2 += b[i];
		sum += b[i] - a[i];
		if (sum < min1) {
			min1 = sum;
			min1i = i;
		}
		if (sum - min1 > max2) {
			max2 = sum - min1;
			max2i = i;
			max2min1i = min1i;
		}
	}

	cout << sum2 - max2;
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Runtime error0/065ms87352 KiB
2Runtime error0/065ms87568 KiB
3Runtime error0/365ms87976 KiB
4Runtime error0/465ms88040 KiB
5Runtime error0/465ms88664 KiB
6Runtime error0/465ms89016 KiB
7Runtime error0/464ms89020 KiB
8Runtime error0/365ms89072 KiB
9Runtime error0/464ms89108 KiB
10Runtime error0/465ms88992 KiB
11Runtime error0/465ms89272 KiB
12Runtime error0/575ms89484 KiB
13Runtime error0/374ms89912 KiB
14Runtime error0/368ms89764 KiB
15Runtime error0/365ms89560 KiB
16Runtime error0/374ms89828 KiB
17Runtime error0/370ms89912 KiB
18Runtime error0/364ms90072 KiB
19Runtime error0/364ms89996 KiB
20Runtime error0/374ms90048 KiB
21Runtime error0/368ms90364 KiB
22Runtime error0/375ms90724 KiB
23Runtime error0/374ms90572 KiB
24Runtime error0/368ms90648 KiB