제출 #82712

#제출 시각아이디문제언어결과실행 시간메모리
82712farukkastamonuda새로운 문제 (POI13_luk)C++14
100 / 100
1090 ms47068 KiB
#include <bits/stdc++.h> #define fi first #define se second #define lo long long #define inf 1000000009 #define md 1000000007 #define li 300005 #define mp make_pair #define pb push_back using namespace std; int n,a,b,sz[li],sz2[li]; vector<int> v[li]; lo int dfs(int node,int ata,int val){ lo int D=0; for(int i=0;i<(int)v[node].size();i++){ int go=v[node][i]; if(go==ata) continue; D+=dfs(go,node,val)+1; } return max(0LL,D-val); } bool ok(int val){ return (dfs(1,-1,val)==0); } int main(){ scanf("%d",&n); for(int i=1;i<n;i++){ scanf("%d %d",&a,&b); v[a].pb(b); v[b].pb(a); } int bas=0,son=n-1; while(bas<=son){ int mid=(bas+son)/2; if(ok(mid)) son=mid-1; else bas=mid+1; } printf("%d\n",bas); return 0; }

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

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