제출 #209745

#제출 시각아이디문제언어결과실행 시간메모리
209745kapsel새로운 문제 (POI13_luk)C++14
100 / 100
862 ms26456 KiB
#include <bits/stdc++.h> using namespace std; #define LL long long #define ULL unsigned long long #define LD long double const int N = 3e5 + 2137; vector<int> V[N]; int spr(int v, int k, int oj) { int n = V[v].size(); LL w = 0; for(int i=0; i<n; i++) { int u = V[v][i]; if(u!=oj) { w+=spr(u, k, v)+1; } } return max((LL)0, w-k); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; int a, b; for(int i=1; i<n; i++) { cin>>a>>b; V[a].push_back(b); V[b].push_back(a); } int poc = 0; int kon = n; while(poc<kon) { int sr = (poc+kon) / 2; if(!spr(1, sr, -1)) kon = sr; else poc = sr + 1; } cout<<poc; }
#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...