# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199621 | Markomafko972 | Traffic (IOI10_traffic) | C++14 | 1599 ms | 151032 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;
vector<int> v[1000002];
int a[1000002];
long long sol[1000002];
long long maxi[1000002];
void dfs(int x, int prt) {
for (int i = 0; i < v[x].size(); i++) {
int sus = v[x][i];
if (sus != prt) {
dfs(sus, x);
sol[x] += sol[sus];
sol[x] += a[sus];
maxi[x] = max(maxi[x], sol[sus]+a[sus]);
}
}
}
int LocateCentre(int n, int p[], int s[], int d[]) {
long long zbr = 0;
for (int i = 0; i < n; i++) a[i] = p[i], zbr += a[i];
for (int i = 0; i < n-1; i ++) {
v[s[i]].push_back(d[i]);
v[d[i]].push_back(s[i]);
}
dfs(1, 0);
long long mini = 1e18;
int w = 0;
for (int i = 0; i < n; i++) {
maxi[i] = max(maxi[i], zbr-sol[i]-a[i]);
if (maxi[i] < mini) {
mini = maxi[i];
w = i;
}
}
return w;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |