답안 #545915

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545915 2022-04-05T16:09:31 Z rainboy Sure Bet (CEOI17_sure) C
100 / 100
101 ms 3568 KB
#include <stdio.h>

#define N	100000

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

unsigned int X = 12345;

int rand_() {
	return (X *= 3) >> 1;
}

void sort(double *aa, int l, int r) {
	while (l < r) {
		int i = l, j = l, k = r;
		double a = aa[l + rand_() % (r - l)], tmp;

		while (j < k)
			if (aa[j] == a)
				j++;
			else if (aa[j] > a) {
				tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = aa[j], aa[j] = aa[k], aa[k] = tmp;
			}
		sort(aa, l, i);
		l = k;
	}
}

int main() {
	static double aa[N], bb[N];
	int n, i, j;
	double sum1, sum2, ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%lf%lf", &aa[i], &bb[i]);
	sort(aa, 0, n);
	sort(bb, 0, n);
	sum1 = sum2 = 0, ans = 0, i = 0, j = 0;
	while (i < n || j < n) {
		if (i < n && (j == n || sum1 <= sum2))
			sum1 += aa[i++];
		else
			sum2 += bb[j++];
		ans = max(ans, min(sum1, sum2) - i - j);
	}
	printf("%.4f\n", ans);
	return 0;
}

Compilation message

sure.c: In function 'main':
sure.c:39:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
sure.c:41:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |   scanf("%lf%lf", &aa[i], &bb[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 78 ms 3148 KB Output is correct
18 Correct 73 ms 3152 KB Output is correct
19 Correct 84 ms 3136 KB Output is correct
20 Correct 75 ms 3200 KB Output is correct
21 Correct 101 ms 3564 KB Output is correct
22 Correct 74 ms 3200 KB Output is correct
23 Correct 73 ms 3196 KB Output is correct
24 Correct 78 ms 3144 KB Output is correct
25 Correct 75 ms 3080 KB Output is correct
26 Correct 83 ms 3568 KB Output is correct