제출 #1080542

#제출 시각아이디문제언어결과실행 시간메모리
1080542batsukh2006새로운 문제 (POI13_luk)C++17
100 / 100
469 ms31356 KiB
#include<iostream> #include<map> #include<set> #include<cmath> #include<queue> #include<deque> #include<stack> #include<string> #include<math.h> #include<vector> #include<stdio.h> #include<utility> #include<iomanip> #include<string.h> #include<limits.h> #include<algorithm> #include<functional> #include<unordered_map> using namespace std; #define MOD 1000000007 #define int long long #define ss second #define ff first #define endl '\n' const int mxN=3e5+1; vector<int> v[mxN],dp(mxN); void dfs(int a, int p, int k){ int need=0; for(auto node: v[a]){ if(node!=p){ dfs(node,a,k); need+=dp[node]+1; } } dp[a]=max(need-k,0ll); } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; for(int i=1; i<n; i++){ int a,b; cin>>a>>b; v[a].push_back(b); v[b].push_back(a); } int l=0,r=n; while(l<=r){ int m=l+(r-l)/2; for(int i=1; i<=n; i++) dp[i]=0; dfs(1,1,m); if(dp[1]==0) r=m-1; else l=m+1; } cout<<l; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...