# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
738803 | LIF | Triumphal arch (POI13_luk) | C++14 | 986 ms | 23676 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>
#include<vector>
using namespace std;
int n;
vector<int> vv[300005];
int check(int cur,int now,int pre)
{
int siz = 0;
for(int i=0;i<vv[now].size();i++)
{
int xx = vv[now][i];
if(xx != pre)
{
siz++;
siz += check(cur,xx,now);
}
}
siz -= cur;
return max(siz,0);
}
int main()
{
cin>>n;
for(int i=1;i<=n-1;i++)
{
int xx,yy;
cin>>xx>>yy;
vv[xx].push_back(yy);
vv[yy].push_back(xx);
}
int l = 0;
int r = n;
int ans = 0;
while(l<=r)
{
int mid = (l+r)>>1;
if(check(mid,1,-1) > 0)
{
l = mid +1;
}
else
{
ans = mid;
r = mid-1;
}
}
cout<<ans<<endl;
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... |