#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define vi vector<int>
#define vpii vector<pii>
#define vp3i vector<p3i>
#define vpll vector<pll>
#define vp3l vector<p3l>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() ((rand() << 14)+rand())
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846
#define startrng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
double ans;
int n, d, x, y;
vector<pll> v;
vector<pll> hull;
//f(x) = x^2 + mx + b
//xa1+b1=xa2+b2
//x=(b2-b1)/(a1-a2);
double eval(pll A, double X){
//cout << A.x << ' ' << A.y << ' ' << X << endl;
return sqrt(X*X+X*A.y+A.x);
}
void check(pll A, pll B){
double x=(B.x-A.x)/double(A.y-B.y);
if (x<0 || x>d) return;
ans = max(eval(A, x), ans);
}
bool cross(pll A, pll O, pll B){
return (A.x-O.x)*(B.y-O.y)-(A.y-O.y)*(B.x-O.x)>=0;
}
int32_t main(){
scanf("%i%i", &n, &d);
fox(l, n){
scanf("%i%i", &x, &y);
v.pb(mp(x, y));
}
sort(v.begin(), v.end());
for (auto i:v){
while(hull.size()>1 && cross(hull[hull.size()-2], hull.back(), i)){
hull.pop_back();
}
hull.pb(mp(i.y*i.y+i.x*i.x, -2*i.x));
}
fox(l, hull.size()-1){
check(hull[l], hull[l+1]);
}
//cout << ans << endl;
double lft=(1LL<<60), rit=(1LL<<60);
fox(l, hull.size()){
lft=min(lft, eval(hull[l], 0));
rit=min(rit, eval(hull[l], d));
}
//cout << lft << ' ' << rit << endl;
ans = max(ans, max(lft, rit));
//cout << sqrt(ans) << endl;
printf("%.8f", ans);
return 0;
}
Compilation message
mobile.cpp: In function 'int32_t main()':
mobile.cpp:23:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
mobile.cpp:68:7:
fox(l, hull.size()-1){
~~~~~~~~~~~~~~~~
mobile.cpp:68:3: note: in expansion of macro 'fox'
fox(l, hull.size()-1){
^~~
mobile.cpp:23:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
mobile.cpp:73:7:
fox(l, hull.size()){
~~~~~~~~~~~~~~
mobile.cpp:73:3: note: in expansion of macro 'fox'
fox(l, hull.size()){
^~~
mobile.cpp:56:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i%i", &n, &d);
~~~~~^~~~~~~~~~~~~~~~
mobile.cpp:58:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i%i", &x, &y);
~~~~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
3304 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
3296 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
5476 KB |
Output is correct |
2 |
Incorrect |
40 ms |
3688 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
40 ms |
3940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
41 ms |
5356 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
159 ms |
24784 KB |
Output is correct |
2 |
Correct |
200 ms |
28240 KB |
Output is correct |
3 |
Correct |
179 ms |
15572 KB |
Output is correct |
4 |
Incorrect |
212 ms |
17876 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
203 ms |
28752 KB |
Output is correct |
2 |
Incorrect |
168 ms |
21968 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
187 ms |
39480 KB |
Output is correct |
2 |
Incorrect |
229 ms |
33284 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
235 ms |
36048 KB |
Output is correct |
2 |
Incorrect |
202 ms |
25532 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
211 ms |
41916 KB |
Output is correct |
2 |
Correct |
279 ms |
46908 KB |
Output is correct |
3 |
Correct |
257 ms |
24656 KB |
Output is correct |
4 |
Incorrect |
320 ms |
27216 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
286 ms |
47420 KB |
Output is correct |
2 |
Incorrect |
242 ms |
33084 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
253 ms |
44348 KB |
Output is correct |
2 |
Correct |
320 ms |
50028 KB |
Output is correct |
3 |
Correct |
290 ms |
24656 KB |
Output is correct |
4 |
Incorrect |
344 ms |
28604 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
327 ms |
50876 KB |
Output is correct |
2 |
Incorrect |
279 ms |
36568 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
312 ms |
49340 KB |
Output is correct |
2 |
Correct |
380 ms |
56124 KB |
Output is correct |
3 |
Incorrect |
350 ms |
30796 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
389 ms |
57432 KB |
Output is correct |
2 |
Incorrect |
336 ms |
43728 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |