답안 #493274

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493274 2021-12-10T16:07:18 Z rainboy Autobahn (COI21_autobahn) C
50 / 100
5 ms 416 KB
#include <stdio.h>

#define N	1000
#define X	2000

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

int main() {
	static int ll[N], rr[N], cc[N], dd[X];
	int n, k, len, i, x, ans, sum;

	scanf("%d%d%d", &n, &k, &len);
	for (i = 0; i < n; i++) {
		scanf("%d%d%d", &ll[i], &cc[i], &rr[i]);
		dd[ll[i]]++, dd[rr[i] + 1]--;
	}
	for (x = 1; x < X; x++)
		dd[x] += dd[x - 1];
	for (x = 1; x < X; x++)
		dd[x] = dd[x] >= k;
	for (x = 1; x < X; x++)
		dd[x] += dd[x - 1];
	ans = 0;
	for (x = 1; x + len - 1 < X; x++) {
		sum = 0;
		for (i = 0; i < n; i++) {
			int l = max(ll[i] + cc[i], x), r = min(rr[i], x + len - 1);

			if (l <= r)
				sum += dd[r] - dd[l - 1];
		}
		ans = max(ans, sum);
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

autobahn.c: In function 'main':
autobahn.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d%d", &n, &k, &len);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
autobahn.c:15:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%d%d%d", &ll[i], &cc[i], &rr[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 4 ms 204 KB Output is correct
13 Correct 4 ms 204 KB Output is correct
14 Correct 4 ms 204 KB Output is correct
15 Correct 5 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 5 ms 288 KB Output is correct
18 Correct 3 ms 204 KB Output is correct
19 Correct 3 ms 204 KB Output is correct
20 Correct 3 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 4 ms 204 KB Output is correct
13 Correct 4 ms 204 KB Output is correct
14 Correct 4 ms 204 KB Output is correct
15 Correct 5 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 5 ms 288 KB Output is correct
18 Correct 3 ms 204 KB Output is correct
19 Correct 3 ms 204 KB Output is correct
20 Correct 3 ms 204 KB Output is correct
21 Runtime error 1 ms 416 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -