#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef double D;
typedef long double LD;
const int N = 1000007;
PLL tower[N];
bool cmp(PLL a, PLL b){
if(a.x != b.x) return a.x > b.x;
return a.y < b.y;
}
PLL intersect(PLL a, PLL b){
LL A, B;
A = a.y - b.y;
B = b.x - a.x;
if(B < 0) A = -A, B = -B;
return {A, B};
}
vector<PLL> line;
void add(PLL nw){
while(SZ(line)>1){
int a = SZ(line);
if(line[a-1].x == nw.x) return;
PLL tmp1 = intersect(line[a-2], line[a-1]);
PLL tmp2 = intersect(line[a-1], nw);
if(tmp2.x*tmp1.y < tmp1.x*tmp2.y) line.pop_back();
else break;
}
line.pb(nw);
}
LD calc(LD a, int b){
return a*line[b].x + line[b].y;
}
LL L;
int n;
int main(){
int i,j;
LL a,b;
scanf("%d %lld",&n,&L);
for(i=1;i<=n;i++){
scanf("%lld%lld",&a,&b);
tower[i] = {-a*2ll, a*a + b*b};
}
sort(tower+1, tower+1+n, cmp);
for(i=1;i<=n;i++){
add(tower[i]);
}
LD ans = 0;
for(i = 0; i < SZ(line)-1; i++){
PLL tmp = intersect(line[i], line[i+1]);
LD tmp2 = (LD)tmp.x/tmp.y;
if(tmp2 < 0 || tmp2 > L) continue;
ans = max(ans, calc(tmp2, i) + tmp2*tmp2);
}
for(i=0; i<SZ(line)-1; i++){
if(calc(0, i) <= calc(0, i+1)) break;
}
ans = max(ans, calc(0, i));
for(i=0; i<SZ(line)-1; i++){
if(calc(L, i) <= calc(L, i+1)) break;
}
ans = max(ans, calc(L, i) + L*L);
printf("%Lf",sqrt(ans));
return 0;
}
/*
2 10
0 0
11 1
*/
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:52:8: warning: unused variable 'j' [-Wunused-variable]
int i,j;
^
mobile.cpp:54:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %lld",&n,&L);
~~~~~^~~~~~~~~~~~~~~~~
mobile.cpp:56:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld",&a,&b);
~~~~~^~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
632 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
476 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
2040 KB |
Output is correct |
2 |
Correct |
28 ms |
2652 KB |
Output is correct |
3 |
Correct |
18 ms |
1912 KB |
Output is correct |
4 |
Correct |
30 ms |
2680 KB |
Output is correct |
5 |
Incorrect |
15 ms |
1528 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
1784 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
4076 KB |
Output is correct |
2 |
Correct |
30 ms |
1944 KB |
Output is correct |
3 |
Correct |
30 ms |
4788 KB |
Output is correct |
4 |
Incorrect |
47 ms |
3832 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
2168 KB |
Output is correct |
2 |
Incorrect |
35 ms |
3448 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
3312 KB |
Output is correct |
2 |
Incorrect |
35 ms |
3280 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
158 ms |
16904 KB |
Output is correct |
2 |
Correct |
170 ms |
8496 KB |
Output is correct |
3 |
Correct |
173 ms |
15480 KB |
Output is correct |
4 |
Incorrect |
228 ms |
18420 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
175 ms |
8680 KB |
Output is correct |
2 |
Correct |
171 ms |
16048 KB |
Output is correct |
3 |
Incorrect |
151 ms |
16228 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
195 ms |
26412 KB |
Output is correct |
2 |
Incorrect |
204 ms |
9932 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
210 ms |
9792 KB |
Output is correct |
2 |
Correct |
205 ms |
18904 KB |
Output is correct |
3 |
Incorrect |
182 ms |
18704 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
229 ms |
28076 KB |
Output is correct |
2 |
Incorrect |
248 ms |
11416 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
249 ms |
11388 KB |
Output is correct |
2 |
Correct |
244 ms |
21764 KB |
Output is correct |
3 |
Incorrect |
217 ms |
21960 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
262 ms |
29548 KB |
Output is correct |
2 |
Incorrect |
277 ms |
13048 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
302 ms |
12988 KB |
Output is correct |
2 |
Correct |
274 ms |
24488 KB |
Output is correct |
3 |
Incorrect |
248 ms |
24556 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
319 ms |
32476 KB |
Output is correct |
2 |
Incorrect |
341 ms |
15992 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
349 ms |
15992 KB |
Output is correct |
2 |
Correct |
347 ms |
31304 KB |
Output is correct |
3 |
Incorrect |
310 ms |
32484 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |