# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
796851 | Liudas | Traffic (IOI10_traffic) | C++17 | 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>
#include "traffic.h"
using namespace std;
int LocateCentre(int N, vector<int> P, vector<int> S, vector<int> D){
vector<int> suf(N), pref(N), sum(N);
for(int i = 1; i < N; i ++){
pref[i] = P[i-1] + pref[i-1];
}
for(int i = N-2; i >= 0; i --){
suf[i] = suf[i + 1] + P[i+1];
}
int ans = 2e9, x = -1;
for(int i = 0; i < N; i ++){
if(max(suf[i], pref[i]) < ans){
ans = max(suf[i], pref[i]);
x = i;
}
}
return x;
}