Submission #544449

# Submission time Handle Problem Language Result Execution time Memory
544449 2022-04-01T23:43:52 Z rainboy Mobile (BOI12_mobile) C
Compilation error
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; }

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:20:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  scanf("%d%d", &n, &x_);
      |  ^~~~~~~~~~~~~~~~~~~~~~
mobile.c:23:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf("%d%d", &xx[i], &yy[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccgUZ8Tu.o: in function `main':
mobile.c:(.text.startup+0x2ed): undefined reference to `hypot'
/usr/bin/ld: mobile.c:(.text.startup+0x312): undefined reference to `hypot'
collect2: error: ld returned 1 exit status