# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88869 | mch | Triumphal arch (POI13_luk) | C++14 | 197 ms | 13532 KiB |
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 <iostream>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
bool isEnough(int nCrew, vector<int> arr[], int n){
int max = arr[n].size();
int left = nCrew - max;
// printf("%d %d %d\n", max, left, nCrew);
if(left < 0) return false;
for(int i = 0; i < max; i++){
int k = arr[n][i];
// printf("%d\n", k);
if(!isEnough(nCrew+left, arr, k)) return false;
}
return true;
}
int main(){
vector<int> arr[300001];
int n, from, to;
scanf("%d", &n);
for(int i = 0; i < n-1; i++){
scanf("%d", &from);
scanf("%d", &to);
arr[min(from-1, to-1)].push_back(max(from-1, to-1));
}
int low = 0;
int high = n-1;
while(low <= high){
int mid = (low + high)/2;
if(isEnough(mid, arr, 0)) high = mid - 1;
else low = mid + 1;
}
printf("%d", low);
return 0;
}
Compilation message (stderr)
# | 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... |