제출 #28941

#제출 시각아이디문제언어결과실행 시간메모리
28941khsoo01새로운 문제 (POI13_luk)C++11
100 / 100
1193 ms23796 KiB
#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); }

컴파일 시 표준 에러 (stderr) 메시지

luk.cpp: In function 'int main()':
luk.cpp:19:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
luk.cpp:22:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&A,&B);
                      ^
#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...