147572025-02-01 19:10:24sarminVásárlás (75 pont)cpp17Wrong answer 9/7523ms2688 KiB
// Created by Armin on 2/1/2025.

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pp = pair<int, int>;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    int n; cin >> n;
    vector<int> a(n), b(n);
    int sumb = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    vector<int> ba(n);
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      sumb += b[i];
      ba[i] = b[i] - a[i];
    }

    int i = 0, j = 0, sum = 0;
    while (i + 1 < n && j + 1 < n) {
      if (sum + ba[j] < 0) {
        j++;
        i = j;
        sum = ba[i];
      } else {
        sum += ba[j];
        j++;
      }
    }
    int d = 0, c = 0;
    for (int k = i; k <= j; k++) {
      d += a[k];
      c += b[k];
    }
    cout << sumb - c + d << '\n';
    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base9/75
1Accepted0/01ms316 KiB
2Wrong answer0/012ms1512 KiB
3Accepted3/31ms316 KiB
4Wrong answer0/41ms508 KiB
5Wrong answer0/41ms316 KiB
6Wrong answer0/41ms316 KiB
7Wrong answer0/41ms316 KiB
8Wrong answer0/31ms316 KiB
9Wrong answer0/42ms440 KiB
10Wrong answer0/41ms436 KiB
11Wrong answer0/41ms316 KiB
12Wrong answer0/51ms508 KiB
13Wrong answer0/323ms2356 KiB
14Wrong answer0/323ms2360 KiB
15Wrong answer0/323ms2356 KiB
16Wrong answer0/321ms2372 KiB
17Wrong answer0/323ms2356 KiB
18Wrong answer0/321ms2492 KiB
19Accepted3/323ms2688 KiB
20Accepted3/323ms2416 KiB
21Wrong answer0/323ms2360 KiB
22Wrong answer0/318ms1848 KiB
23Wrong answer0/323ms2396 KiB
24Wrong answer0/321ms2548 KiB