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>
#define pow(x, y) (double)(pow(x, y))
using namespace std;
struct coord{
int x, y;
};
vector <coord> a;
int N, L;
/*double dis(int ax, ay, double ans) {
return (double)(sqrt(pow(ay, 2) + pow(ax - ans, 2)));
}
double distance(int i, int j) {
long long num = pow(a[i].y, 2) - pow(a[j].y, 2) - pow(a[j].x, 2) + pow(a[i].x, 2);
long long den = 2 * (-a[j].x + a[i].x);
if (den == 0) return sqrt(num);
double frac = (double)(num) / (double)(den);
return frac;
}*/
bool solve(double mid) {
double right(0);
for (int i(0); i < a.size(); i++) {
if (abs(a[i].y) > mid) continue;
double iLeft = (double)(a[i].x) - (double)(sqrt(mid * mid - double(a[i].y) * double(a[i].y)));
double iRight = a[i].x + (a[i].x - iLeft);
if (iLeft <= right) right = max(right,iRight);
}
return (right >= L);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> L;
a.clear();
int x, y; cin >> x >> y;
a.push_back({x, y});
for (int i(0); i < N - 1; i++) {
int ax, ay;
cin >> ax >> ay;
if (ax == a[(int)(a.size() - 1)].x){
if (abs(ay) < abs(a[(int)(a.size() - 1)].y)) {
a[(int)(a.size() - 1)].y = ay;
}
else continue;
}
a.push_back({ax, ay});
}
double l(0), r(1e9);
while (r - l > 0.0003) {
double mid = l + (r - l) / 2;
if (solve(mid)){
r = mid;
}
else l = mid;
}
cout << setprecision(5) << fixed << l << '\n';
return 0;
}
Compilation message (stderr)
mobile.cpp: In function 'bool solve(double)':
mobile.cpp:25:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<coord>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for (int i(0); i < a.size(); i++) {
| ~~^~~~~~~~~~
# | 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... |