# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28941 | khsoo01 | Triumphal arch (POI13_luk) | C++11 | 1193 ms | 23796 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;
const int N = 300005;
int n, v[N], cur;
vector<int> adj[N];
void solve (int C, int P) {
v[C] = cur - (int)adj[C].size() + !!P;
for(auto &T : adj[C]) {
if(T == P) continue;
solve(T, C);
if(v[T] < 0) v[C] += v[T];
}
}
int main()
{
scanf("%d",&n);
for(int i=1;i<n;i++) {
int A, B;
scanf("%d%d",&A,&B);
adj[A].push_back(B);
adj[B].push_back(A);
}
int S = 0, E = n;
while(S < E) {
int M = (S+E)/2;
cur = M; solve(1, 0);
v[1] < 0 ? S = M+1 : E = M;
}
printf("%d\n",S);
}
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... |