# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28973 | tlwpdus | Triumphal arch (POI13_luk) | C++11 | 1339 ms | 25192 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 n, t;
vector<int> lis[300100];
int d[300100];
void dfs(int here, int p) {
int i, sum = 0;
for (auto &there : lis[here]) {
if (there==p) continue;
dfs(there,here);
sum += d[there];
}
d[here] = max(sum-t+1,1);
}
int main() {
int i;
scanf("%d",&n);
for (i=0;i<n-1;i++) {
int a, b;
scanf("%d%d",&a,&b); --a; --b;
lis[a].push_back(b); lis[b].push_back(a);
}
int s = 0, e = n;
while(s<=e) {
int m = (s+e)>>1;
t = m;
dfs(0,-1);
if (d[0]>1) s = m+1;
else e = m-1;
}
printf("%d\n",s);
return 0;
}
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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |