Submission #544736

# Submission time Handle Problem Language Result Execution time Memory
544736 2022-04-02T16:15:35 Z rainboy Martian DNA (BOI18_dna) C
100 / 100
37 ms 3724 KB
#include <stdio.h>

#define N	200000

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

int main() {
	static int aa[N], kk[N];
	int n, k, r, i, j, ans;

	scanf("%d%d%d", &n, &k, &r);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	for (i = 0; i < r; i++) {
		int a;

		scanf("%d%d", &a, &k);
		kk[a] = k;
	}
	ans = n + 1;
	for (i = 0, j = 0; j < n; j++) {
		if (--kk[aa[j]] == 0)
			r--;
		while (kk[aa[i]] < 0)
			kk[aa[i++]]++;
		if (r == 0)
			ans = min(ans, j - i + 1);
	}
	if (ans == n + 1)
		printf("impossible\n");
	else
		printf("%d\n", ans);
	return 0;
}

Compilation message

dna.c: In function 'main':
dna.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d%d%d", &n, &k, &r);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
dna.c:13:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
dna.c:17:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d%d", &a, &k);
      |   ^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 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 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 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 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 296 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1400 KB Output is correct
2 Correct 16 ms 1460 KB Output is correct
3 Correct 19 ms 1400 KB Output is correct
4 Correct 16 ms 1476 KB Output is correct
5 Correct 18 ms 2452 KB Output is correct
6 Correct 14 ms 1452 KB Output is correct
7 Correct 17 ms 1612 KB Output is correct
8 Correct 22 ms 3020 KB Output is correct
9 Correct 18 ms 2004 KB Output is correct
10 Correct 16 ms 1464 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 300 KB Output is correct
19 Correct 0 ms 292 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3084 KB Output is correct
2 Correct 29 ms 2836 KB Output is correct
3 Correct 22 ms 2588 KB Output is correct
4 Correct 16 ms 1464 KB Output is correct
5 Correct 31 ms 3532 KB Output is correct
6 Correct 37 ms 3724 KB Output is correct
7 Correct 19 ms 2004 KB Output is correct
8 Correct 26 ms 2192 KB Output is correct
9 Correct 15 ms 1364 KB Output is correct
10 Correct 16 ms 1408 KB Output is correct
11 Correct 17 ms 1444 KB Output is correct
12 Correct 16 ms 1364 KB Output is correct
13 Correct 22 ms 2508 KB Output is correct
14 Correct 15 ms 1364 KB Output is correct
15 Correct 16 ms 1560 KB Output is correct
16 Correct 22 ms 3044 KB Output is correct
17 Correct 17 ms 1976 KB Output is correct
18 Correct 17 ms 1464 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 0 ms 296 KB Output is correct
33 Correct 0 ms 212 KB Output is correct