Submission #544458

# Submission time Handle Problem Language Result Execution time Memory
544458 2022-04-02T00:00:03 Z rainboy Mobile (BOI12_mobile) C++
100 / 100
285 ms 35280 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.cpp: In function 'int main()':
mobile.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  scanf("%d%d", &n, &x_);
      |  ~~~~~^~~~~~~~~~~~~~~~~
mobile.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf("%d%d", &xx[i], &yy[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 444 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 440 KB Output is correct
2 Correct 2 ms 444 KB Output is correct
3 Correct 2 ms 444 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 2292 KB Output is correct
2 Correct 17 ms 2600 KB Output is correct
3 Correct 16 ms 1692 KB Output is correct
4 Correct 20 ms 2540 KB Output is correct
5 Correct 9 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2264 KB Output is correct
2 Correct 18 ms 2144 KB Output is correct
3 Correct 19 ms 2592 KB Output is correct
4 Correct 20 ms 2724 KB Output is correct
5 Correct 23 ms 3096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2636 KB Output is correct
2 Correct 19 ms 2740 KB Output is correct
3 Correct 20 ms 2772 KB Output is correct
4 Correct 31 ms 3776 KB Output is correct
5 Correct 19 ms 2544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 3332 KB Output is correct
2 Correct 22 ms 3180 KB Output is correct
3 Correct 19 ms 2892 KB Output is correct
4 Correct 33 ms 3788 KB Output is correct
5 Correct 23 ms 3012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 3520 KB Output is correct
2 Correct 22 ms 3232 KB Output is correct
3 Correct 20 ms 2864 KB Output is correct
4 Correct 28 ms 3796 KB Output is correct
5 Correct 23 ms 3020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 102 ms 14284 KB Output is correct
2 Correct 118 ms 15736 KB Output is correct
3 Correct 107 ms 15324 KB Output is correct
4 Correct 138 ms 17588 KB Output is correct
5 Correct 124 ms 14848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 139 ms 16280 KB Output is correct
2 Correct 109 ms 14944 KB Output is correct
3 Correct 105 ms 14156 KB Output is correct
4 Correct 133 ms 17460 KB Output is correct
5 Correct 125 ms 15528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 120 ms 17108 KB Output is correct
2 Correct 132 ms 18864 KB Output is correct
3 Correct 129 ms 18292 KB Output is correct
4 Correct 183 ms 21588 KB Output is correct
5 Correct 141 ms 17672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 150 ms 19536 KB Output is correct
2 Correct 127 ms 17736 KB Output is correct
3 Correct 120 ms 16716 KB Output is correct
4 Correct 168 ms 21336 KB Output is correct
5 Correct 148 ms 18324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 139 ms 20124 KB Output is correct
2 Correct 157 ms 22036 KB Output is correct
3 Correct 163 ms 21328 KB Output is correct
4 Correct 190 ms 24808 KB Output is correct
5 Correct 156 ms 20268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 180 ms 22744 KB Output is correct
2 Correct 153 ms 20740 KB Output is correct
3 Correct 151 ms 20120 KB Output is correct
4 Correct 185 ms 24544 KB Output is correct
5 Correct 163 ms 21300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 174 ms 22876 KB Output is correct
2 Correct 177 ms 25180 KB Output is correct
3 Correct 164 ms 24436 KB Output is correct
4 Correct 220 ms 28428 KB Output is correct
5 Correct 186 ms 23980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 185 ms 26024 KB Output is correct
2 Correct 181 ms 23568 KB Output is correct
3 Correct 179 ms 22776 KB Output is correct
4 Correct 216 ms 28224 KB Output is correct
5 Correct 182 ms 24384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 234 ms 28612 KB Output is correct
2 Correct 216 ms 31448 KB Output is correct
3 Correct 212 ms 30412 KB Output is correct
4 Correct 268 ms 35136 KB Output is correct
5 Correct 235 ms 29488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 230 ms 32352 KB Output is correct
2 Correct 251 ms 29380 KB Output is correct
3 Correct 218 ms 28780 KB Output is correct
4 Correct 285 ms 35280 KB Output is correct
5 Correct 235 ms 30684 KB Output is correct