Submission #544780

# Submission time Handle Problem Language Result Execution time Memory
544780 2022-04-02T16:43:52 Z rainboy Balloons (CEOI11_bal) C
Compilation error
0 ms 0 KB
#include <math.h>
#include <stdio.h>

#define N	200000

double min(double a, double b) { return a < b ? a : b; }

int xx[N]; double yy[N], yy_[N];

double f(int i, int j) {
	return (xx[j] * yy_[i] - xx[i] * yy_[j]) / (yy_[i] - yy_[j]);
}

int main() {
	static int qu[N];
	int n, i, cnt;

	scanf("%d", &n);
	cnt = 0;
	for (i = 0; i < n; i++) {
		int r, i_;

		scanf("%d%d", &xx[i], &r);
		while (cnt >= 2 && f(qu[cnt - 2], qu[cnt - 1]) <= xx[i])
			cnt--;
		i_ = cnt == 0 ? -1 : qu[cnt - 1];
		yy[i] = cnt == 0 ? r : min(r, (double) (xx[i] - xx[i_]) * (xx[i] - xx[i_]) / 4 / yy[i_]);
		yy_[i] = sqrt(yy[i]);
		printf("%f\n", yy[i]);
		while (cnt && (yy[qu[cnt - 1]] <= yy[i] || cnt >= 2 && f(qu[cnt - 2], qu[cnt - 1]) <= f(qu[cnt - 1], i)))
			cnt--;
		qu[cnt++] = i;
	}
	return 0;
}

Compilation message

bal.c: In function 'main':
bal.c:30:55: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   30 |   while (cnt && (yy[qu[cnt - 1]] <= yy[i] || cnt >= 2 && f(qu[cnt - 2], qu[cnt - 1]) <= f(qu[cnt - 1], i)))
      |                                              ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.c:18:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
bal.c:23:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf("%d%d", &xx[i], &r);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccgLWgsW.o: in function `main':
bal.c:(.text.startup+0x326): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status