87502024-01-28 17:26:52IgnácVásárlás (75 pont)cpp17Wrong answer 66/7565ms7140 KiB
// Source: https://usaco.guide/general/io

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

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

	long long sum = 0, sum2 = 0, min1 = LLONG_MAX, max2 = LLONG_MIN, min1i = 0, max2i = 0, max2min1i = 0;
	for (long long 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/032ms3408 KiB
3Wrong answer0/33ms2408 KiB
4Accepted4/43ms2516 KiB
5Accepted4/43ms2724 KiB
6Accepted4/43ms2944 KiB
7Accepted4/43ms3072 KiB
8Accepted3/33ms3420 KiB
9Accepted4/44ms3216 KiB
10Accepted4/44ms3436 KiB
11Accepted4/44ms3556 KiB
12Accepted5/54ms3660 KiB
13Accepted3/361ms6776 KiB
14Accepted3/364ms6752 KiB
15Accepted3/363ms6756 KiB
16Accepted3/363ms6752 KiB
17Accepted3/363ms6752 KiB
18Accepted3/364ms6752 KiB
19Wrong answer0/361ms7084 KiB
20Wrong answer0/364ms7140 KiB
21Accepted3/364ms7028 KiB
22Accepted3/346ms7032 KiB
23Accepted3/365ms7044 KiB
24Accepted3/361ms7108 KiB