87482024-01-28 17:24:58IgnácVásárlás (75 pont)cpp17Wrong answer 66/7561ms16704 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
base66/75
1Accepted0/03ms1816 KiB
2Accepted0/030ms3268 KiB
3Wrong answer0/33ms2748 KiB
4Accepted4/43ms2828 KiB
5Accepted4/43ms3040 KiB
6Accepted4/43ms3256 KiB
7Accepted4/43ms3620 KiB
8Accepted3/33ms3780 KiB
9Accepted4/44ms4028 KiB
10Accepted4/44ms4020 KiB
11Accepted4/44ms4060 KiB
12Accepted5/54ms4080 KiB
13Accepted3/359ms6412 KiB
14Accepted3/359ms7356 KiB
15Accepted3/359ms8336 KiB
16Accepted3/359ms9284 KiB
17Accepted3/359ms10268 KiB
18Accepted3/359ms11196 KiB
19Wrong answer0/357ms12152 KiB
20Wrong answer0/359ms13064 KiB
21Accepted3/361ms14048 KiB
22Accepted3/341ms14644 KiB
23Accepted3/361ms15740 KiB
24Accepted3/359ms16704 KiB