# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133183 | sealnot123 | Mobile (BOI12_mobile) | C++14 | 352 ms | 32728 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<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((__int128)tmp2.x*(__int128)tmp1.y <= (__int128)tmp1.x*(__int128)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, dist0 = 2e18+2, distL = 2e18+2;
LD ans;
scanf("%d %lld",&n,&L);
for(i=1;i<=n;i++){
scanf("%lld%lld",&a,&b);
dist0 = min(dist0, a*a + b*b);
distL = min(distL, (L-a)*(L-a) + b*b);
tower[i] = {-a*2ll, a*a + b*b};
}
ans = (LD)max(dist0, distL);
for(i=1;i<=n;i++) add(tower[i]);
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);
}
printf("%Lf",sqrt(ans));
return 0;
}
/*
2 10
0 0
11 1
3 10
1 0
5 0
10 0
2 10
-5 3
12 2
*/
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... |
# | 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... |