이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, l;
vector <pair<double, double>> towers;
vector <pair<double ,double>> intervals;
bool good(double dist){
intervals.clear();
//get_intervals
double mx = 0;
for(const auto &tower : towers){
if(tower.second>dist){
intervals.emplace_back(0, 0);
continue;
}
double range = sqrt((dist*dist)-(tower.second*tower.second));
intervals.emplace_back(tower.first-range, tower.first+range);
mx = max(mx, tower.first+range);
}
sort(intervals.begin(), intervals.end());
if(intervals[0].first>0 || mx<l){
return false;
}
double curr_max = intervals[0].second;
for(int i = 1; i < (int) intervals.size(); i++){
if(intervals[i].first>l){
return true;
}
if(curr_max<intervals[i].first){
return false;
}
curr_max=max(curr_max, intervals[i].second);
}
return true;
}
int main() {
// your code goes here
cin >> n >> l;
towers.resize(n);
for(int i = 0; i < n; i++){
cin >> towers[i].first >> towers[i].second;
}
double s = 0, e = 3000000000, mid;
while(e-s>0.001){
mid = (s+e)/2;
if(good(mid)){
e=mid;
}
else{
s=mid;
}
}
cout << e << "\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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |