Submission #679184

# Submission time Handle Problem Language Result Execution time Memory
679184 2023-01-07T16:28:50 Z rainboy Worst Reporter 3 (JOI18_worst_reporter3) C
100 / 100
368 ms 22740 KB
#include <stdio.h>

#define N	500000
#define K	32	/* K = ceil(log2(2 * 10^9)) + 1 */

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 aa[N + 1], ii[K];
	int n, q, k, h, i, j;

	scanf("%d%d", &n, &q);
	aa[0] = 1;
	for (i = 1; i <= n; i++)
		scanf("%d", &aa[i]);
	for (i = 1; i <= n; i++)
		aa[i] = ((long long) aa[i] + aa[i - 1] - 1) / aa[i - 1] * aa[i - 1];
	k = 0;
	for (i = 0; i <= n; i++)
		if (i == 0 || aa[i] != aa[i - 1])
			ii[k++] = i;
	while (q--) {
		int t, l, r, x, ans;

		scanf("%d%d%d", &t, &l, &r);
		ans = 0;
		for (h = 0; h < k; h++) {
			i = ii[h], j = h + 1 == k ? n : ii[h + 1] - 1, x = t / aa[i] * aa[i];
			ans += max(min(x - i, r) - max(x - j, l) + 1, 0);
		}
		printf("%d\n", ans);
	}
	return 0;
}

Compilation message

worst_reporter3.c: In function 'main':
worst_reporter3.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d", &n, &q);
      |  ^~~~~~~~~~~~~~~~~~~~~
worst_reporter3.c:16:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
worst_reporter3.c:26:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%d%d%d", &t, &l, &r);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 258 ms 5324 KB Output is correct
2 Correct 270 ms 5240 KB Output is correct
3 Correct 262 ms 5184 KB Output is correct
4 Correct 258 ms 5196 KB Output is correct
5 Correct 247 ms 5196 KB Output is correct
6 Correct 264 ms 5136 KB Output is correct
# Verdict Execution time Memory 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 258 ms 5324 KB Output is correct
2 Correct 270 ms 5240 KB Output is correct
3 Correct 262 ms 5184 KB Output is correct
4 Correct 258 ms 5196 KB Output is correct
5 Correct 247 ms 5196 KB Output is correct
6 Correct 264 ms 5136 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 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 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 275 ms 14212 KB Output is correct
14 Correct 273 ms 19748 KB Output is correct
15 Correct 272 ms 18340 KB Output is correct
16 Correct 272 ms 18936 KB Output is correct
17 Correct 347 ms 6532 KB Output is correct
18 Correct 331 ms 6516 KB Output is correct
19 Correct 360 ms 6396 KB Output is correct
20 Correct 341 ms 6604 KB Output is correct
21 Correct 332 ms 6476 KB Output is correct
22 Correct 359 ms 6504 KB Output is correct
23 Correct 331 ms 6464 KB Output is correct
24 Correct 341 ms 6452 KB Output is correct
25 Correct 267 ms 20708 KB Output is correct
26 Correct 271 ms 20556 KB Output is correct
27 Correct 344 ms 22740 KB Output is correct
28 Correct 362 ms 10180 KB Output is correct
29 Correct 368 ms 22580 KB Output is correct
30 Correct 359 ms 22732 KB Output is correct
31 Correct 355 ms 13088 KB Output is correct
32 Correct 265 ms 19184 KB Output is correct
33 Correct 0 ms 212 KB Output is correct