42812023-03-21 19:31:57xxxVásárlás (75 pont)cpp14Accepted 75/7561ms6700 KiB
#include <bits/stdc++.h>
using namespace std;


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

    int ossz = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ossz += b[i] - a[i];
        ans = max(ans, ossz);
        if (ossz < 0) {
            ossz = 0;
        }
    }

    cout << bossz - ans << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1872 KiB
2Accepted0/030ms3288 KiB
3Accepted3/33ms2372 KiB
4Accepted4/43ms2524 KiB
5Accepted4/43ms2636 KiB
6Accepted4/42ms2708 KiB
7Accepted4/43ms2848 KiB
8Accepted3/33ms3056 KiB
9Accepted4/44ms3152 KiB
10Accepted4/44ms3156 KiB
11Accepted4/44ms3276 KiB
12Accepted5/53ms3360 KiB
13Accepted3/359ms5892 KiB
14Accepted3/359ms6004 KiB
15Accepted3/359ms6080 KiB
16Accepted3/361ms6188 KiB
17Accepted3/359ms6272 KiB
18Accepted3/359ms6272 KiB
19Accepted3/357ms6364 KiB
20Accepted3/359ms6492 KiB
21Accepted3/361ms6492 KiB
22Accepted3/341ms6496 KiB
23Accepted3/361ms6572 KiB
24Accepted3/359ms6700 KiB