이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define sz(a) ((int)(a).size())
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef long long ll;
#ifndef wambule
// #include ".h"
#else
#endif
const int inf = 2e9;
const int N = 1000006;
int *p, a, fp = inf, fw;
vector<int> v[N];
int sgd(int x, int op) {
int z = p[x], m = 0, t;
for(int y : v[x]) {
if(y != op) {
z += (t = sgd(y, x));
m = max(m, t);
}
}
m = max(m, a - z);
if(fp > m) {
fp = m;
fw = x;
}
return z;
}
int LocateCentre(int n, int _p[], int x[], int y[]) {
p = _p;
for(int i = 0; i < n; ++i) {
a += p[i];
}
for(int i = 0; i < n - 1; ++i) {
v[x[i]].push_back(y[i]);
v[y[i]].push_back(x[i]);
}
sgd(0, -1);
return fw;
}
#ifdef wambule
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
return 0;
}
#endif
| # | 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... |