78832024-01-11 17:54:22AblablablaVásárlás (75 pont)cpp17Accepted 75/7561ms17652 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;

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

    int maxi = 0;
    int akt = 0;

    for(int i = 0; i < n; i++){
        akt += b[i] - a[i];
        maxi = max(maxi, akt);

        if(akt < 0){
            akt = 0;
        }
    }

    cout << ossz - maxi << "\n";
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1844 KiB
2Accepted0/030ms3316 KiB
3Accepted3/33ms2832 KiB
4Accepted4/43ms3016 KiB
5Accepted4/43ms3108 KiB
6Accepted4/43ms3252 KiB
7Accepted4/43ms3488 KiB
8Accepted3/33ms3536 KiB
9Accepted4/44ms3644 KiB
10Accepted4/44ms3936 KiB
11Accepted4/44ms4188 KiB
12Accepted5/54ms4308 KiB
13Accepted3/357ms6536 KiB
14Accepted3/359ms7716 KiB
15Accepted3/359ms8704 KiB
16Accepted3/359ms9600 KiB
17Accepted3/359ms10560 KiB
18Accepted3/359ms11692 KiB
19Accepted3/357ms12548 KiB
20Accepted3/359ms13712 KiB
21Accepted3/361ms14896 KiB
22Accepted3/343ms15312 KiB
23Accepted3/361ms16412 KiB
24Accepted3/357ms17652 KiB