# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314755 | wind_reaper | 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 "traffic.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> edges;
int LocateCentre(int n, int p[], int s[], int d[]){
edges.resize(n);
vector<int> pref(n);
pref[0] = p[0];
for(int i = 1; i < n; i++)
pref[i] = pref[i-1] + p[i];
vector<int> suf(n);
suf[n-1] = p[n-1];
for(int i = n-2; i >= 0; --i)
suf[i] = suf[i+1] + p[i];
int centre = 0;
int cur_min = INF;
for(int i = 0; i < n; i++){
if(max(pref[i] - p[i], suf[i] - p[i]) < cur_min){
centre = i;
cur_min = max(pref[i] - p[i], suf[i] - p[i]);
}
}
return centre;
}