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>
using namespace std;
const int MAXN = 300005;
vector<int> adj[MAXN];
int depth[MAXN], tot[MAXN];
int main(){
cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n; cin >> n;
for(int a, b, i = 1; i < n; ++i){
cin >> a >> b; adj[a].push_back(b); adj[b].push_back(a);
}
queue<int> q; q.push(1); depth[1] = 1; tot[1] = 1;
while(!q.empty()){
int no = q.front(); q.pop();
for(auto i : adj[no]){
if(depth[i] != 0) continue;
depth[i] = depth[no] + 1;
tot[depth[i]]++;
q.push(i);
}
}
int ans = 0, tasks = 0;
for(int i = 2; i <= n; ++i){
int must = tot[i];
tasks += must;
while((i - 1) * ans < tasks) ++ans;
}
cout << ans << '\n';
return 0;
}
# | 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... |