# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
544457 |
2022-04-01T23:59:40 Z |
rainboy |
Mobile (BOI12_mobile) |
C |
|
0 ms |
0 KB |
#include <math.h>
#include <stdio.h>
#define N 1000000
double min(double a, double b) { return a < b ? a : b; }
double max(double a, double b) { return a > b ? a : b; }
double hypot(double x, double y) { return sqrt(x * x + y * y); }
int xx[N], yy[N]; long long zz[N];
double f(int i, int j) {
return (double) (zz[i] - zz[j]) / (xx[i] - xx[j]) / 2;
}
int main() {
static int qu[N];
int n, x_, h, i, cnt;
double ans;
scanf("%d%d", &n, &x_);
cnt = 0;
for (i = 0; i < n; i++) {
scanf("%d%d", &xx[i], &yy[i]);
if (yy[i] < 0)
yy[i] = -yy[i];
zz[i] = (long long) xx[i] * xx[i] + (long long) yy[i] * yy[i];
if (cnt && xx[i] == xx[qu[cnt - 1]]) {
if (yy[qu[cnt - 1]] > yy[i])
cnt--;
else
continue;
}
while (cnt >= 2 && f(qu[cnt - 2], qu[cnt - 1]) > f(qu[cnt - 1], i))
cnt--;
qu[cnt++] = i;
}
ans = 0;
for (h = 0; h < cnt; h++) {
double l = h == 0 ? 0 : max(f(qu[h - 1], qu[h]), 0);
double r = h + 1 == cnt ? x_ : min(f(qu[h], qu[h + 1]), x_);
int x = xx[qu[h]], y = yy[qu[h]];
if (l <= r)
ans = max(ans, max(hypot(x - l, y), hypot(x - r, y)));
}
printf("%f\n", ans);
return 0;
}
Compilation message
mobile.c: In function 'main':
mobile.c:21:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
21 | scanf("%d%d", &n, &x_);
| ^~~~~~~~~~~~~~~~~~~~~~
mobile.c:24:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
24 | scanf("%d%d", &xx[i], &yy[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccmiLmYt.o: in function `hypot':
mobile.c:(.text+0x40): undefined reference to `sqrt'
/usr/bin/ld: /tmp/ccmiLmYt.o: in function `main':
mobile.c:(.text.startup+0x36f): undefined reference to `sqrt'
/usr/bin/ld: mobile.c:(.text.startup+0x3b4): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status