# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
556280 | Truitadepatates | Traffic (IOI10_traffic) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long int n;
cin >> n;
vector<long long int> v(n);
long long int sum = 0;
for (int i = 0; i < n; i++){
cin >> v[i];
sum += v[i];
}
long long int a, b;
for (int i = 0; i < n-1; i++){
cin >> a >> b;
}
long long int ans = sum + 7;
long long int r = sum;
long long int l = 0;
int ans_ = -1;
for (int i = 0; i < n; i++){
r -= v[i];
if (max(l, r) < ans) ans = max(l, r), ans_ = i;
l += v[i];
}
cout << ans_ << endl;
return 0;
}