56342023-08-30 18:04:28TomaSajtVásárlás (75 pont)cpp17Wrong answer 21/7526ms20760 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0), ios::sync_with_stdio(0);

  int n;
  cin >> n;

  vector<int> a(n), b(n);
  for (int& ai : a) cin >> ai;
  for (int& bi : b) cin >> bi;

  vector<int> pref_a(n + 1), pref_b(n + 1), suff_a(n + 1), suff_b(n + 1);
  partial_sum(a.begin(), a.end(), pref_a.begin() + 1);
  partial_sum(a.rbegin(), a.rend(), suff_a.rbegin() + 1);
  partial_sum(b.begin(), b.end(), pref_b.begin() + 1);
  partial_sum(b.rbegin(), b.rend(), suff_b.rbegin() + 1);

  int best = INT_MAX;
  for (int i = 0; i <= n; i++) {
    best = min({best, pref_a[i] + suff_b[i], pref_b[i] + suff_a[i]});
  }
  cout << best;
}
SubtaskSumTestVerdictTimeMemory
base21/75
1Accepted0/03ms1828 KiB
2Wrong answer0/014ms4944 KiB
3Accepted3/33ms3036 KiB
4Wrong answer0/43ms3000 KiB
5Wrong answer0/43ms3216 KiB
6Accepted4/43ms3284 KiB
7Wrong answer0/43ms3648 KiB
8Wrong answer0/33ms3980 KiB
9Wrong answer0/43ms3988 KiB
10Wrong answer0/43ms4212 KiB
11Wrong answer0/43ms4224 KiB
12Accepted5/53ms4452 KiB
13Wrong answer0/326ms10008 KiB
14Wrong answer0/325ms11196 KiB
15Wrong answer0/325ms12248 KiB
16Wrong answer0/325ms13196 KiB
17Wrong answer0/325ms14156 KiB
18Wrong answer0/325ms15188 KiB
19Accepted3/325ms16276 KiB
20Accepted3/325ms17400 KiB
21Wrong answer0/325ms18460 KiB
22Wrong answer0/320ms18944 KiB
23Wrong answer0/325ms19824 KiB
24Accepted3/325ms20760 KiB