답안 #1013586

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013586 2024-07-03T16:50:14 Z rainboy Trains (BOI24_trains) C
100 / 100
121 ms 127432 KB
#include <stdio.h>

#define N	100000
#define D	316	/* D = floor(sqrt(N)) */
#define MD	1000000007

int main() {
	static int dd[N], ll[N], dp[N], dq[N][D + 1];
	int n, i, j, d, l, k;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d%d", &dd[i], &ll[i]);
	for (i = n - 1; i >= 0; i--) {
		d = dd[i], l = ll[i];
		if (d == 0 || l == 0)
			dp[i] = 1;
		else if (d <= D)
			dp[i] = ((i + d < n ? dq[i + d][d] : 0) - (l < (n - 1 - i) / d ? dq[i + d * (l + 1)][d] : 0) + 1 + MD) % MD;
		else {
			dp[i] = 1;
			for (k = 1; k <= l && (j = i + d * k) < n; k++)
				dp[i] = (dp[i] + dp[j]) % MD;
		}
		for (d = 1; d <= D; d++)
			dq[i][d] = ((i + d < n ? dq[i + d][d] : 0) + dp[i]) % MD;
	}
	printf("%d\n", dp[0]);
	return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
Main.c:13:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d%d", &dd[i], &ll[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 9 ms 10844 KB Output is correct
21 Correct 5 ms 3932 KB Output is correct
22 Correct 12 ms 12928 KB Output is correct
23 Correct 7 ms 8536 KB Output is correct
24 Correct 5 ms 5464 KB Output is correct
25 Correct 9 ms 11528 KB Output is correct
26 Correct 5 ms 5980 KB Output is correct
27 Correct 9 ms 11100 KB Output is correct
28 Correct 11 ms 12924 KB Output is correct
29 Correct 11 ms 12892 KB Output is correct
30 Correct 11 ms 12900 KB Output is correct
31 Correct 11 ms 12892 KB Output is correct
32 Correct 11 ms 12892 KB Output is correct
33 Correct 10 ms 12772 KB Output is correct
34 Correct 10 ms 12892 KB Output is correct
35 Correct 12 ms 12892 KB Output is correct
36 Correct 11 ms 12892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 7 ms 8472 KB Output is correct
3 Correct 5 ms 5876 KB Output is correct
4 Correct 9 ms 11100 KB Output is correct
5 Correct 79 ms 97364 KB Output is correct
6 Correct 96 ms 126356 KB Output is correct
7 Correct 107 ms 126424 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 11 ms 12888 KB Output is correct
12 Correct 105 ms 126800 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 10 ms 12892 KB Output is correct
15 Correct 95 ms 126736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 61176 KB Output is correct
2 Correct 43 ms 50928 KB Output is correct
3 Correct 104 ms 126808 KB Output is correct
4 Correct 71 ms 90960 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 10 ms 12892 KB Output is correct
8 Correct 103 ms 126812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 9 ms 10844 KB Output is correct
21 Correct 5 ms 3932 KB Output is correct
22 Correct 12 ms 12928 KB Output is correct
23 Correct 7 ms 8536 KB Output is correct
24 Correct 5 ms 5464 KB Output is correct
25 Correct 9 ms 11528 KB Output is correct
26 Correct 5 ms 5980 KB Output is correct
27 Correct 9 ms 11100 KB Output is correct
28 Correct 11 ms 12924 KB Output is correct
29 Correct 11 ms 12892 KB Output is correct
30 Correct 11 ms 12900 KB Output is correct
31 Correct 11 ms 12892 KB Output is correct
32 Correct 11 ms 12892 KB Output is correct
33 Correct 10 ms 12772 KB Output is correct
34 Correct 10 ms 12892 KB Output is correct
35 Correct 12 ms 12892 KB Output is correct
36 Correct 11 ms 12892 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 7 ms 8472 KB Output is correct
39 Correct 5 ms 5876 KB Output is correct
40 Correct 9 ms 11100 KB Output is correct
41 Correct 79 ms 97364 KB Output is correct
42 Correct 96 ms 126356 KB Output is correct
43 Correct 107 ms 126424 KB Output is correct
44 Correct 0 ms 600 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 11 ms 12888 KB Output is correct
48 Correct 105 ms 126800 KB Output is correct
49 Correct 0 ms 344 KB Output is correct
50 Correct 10 ms 12892 KB Output is correct
51 Correct 95 ms 126736 KB Output is correct
52 Correct 53 ms 61176 KB Output is correct
53 Correct 43 ms 50928 KB Output is correct
54 Correct 104 ms 126808 KB Output is correct
55 Correct 71 ms 90960 KB Output is correct
56 Correct 0 ms 344 KB Output is correct
57 Correct 0 ms 348 KB Output is correct
58 Correct 10 ms 12892 KB Output is correct
59 Correct 103 ms 126812 KB Output is correct
60 Correct 89 ms 105556 KB Output is correct
61 Correct 97 ms 126544 KB Output is correct
62 Correct 99 ms 126120 KB Output is correct
63 Correct 109 ms 126292 KB Output is correct
64 Correct 113 ms 127432 KB Output is correct
65 Correct 121 ms 126752 KB Output is correct
66 Correct 100 ms 126652 KB Output is correct
67 Correct 100 ms 127056 KB Output is correct
68 Correct 104 ms 126560 KB Output is correct
69 Correct 111 ms 126288 KB Output is correct
70 Correct 121 ms 126552 KB Output is correct
71 Correct 98 ms 126428 KB Output is correct
72 Correct 98 ms 126484 KB Output is correct