Submission #314011

# Submission time Handle Problem Language Result Execution time Memory
314011 2020-10-17T20:25:50 Z Temmie Martian DNA (BOI18_dna) C++17
100 / 100
39 ms 4864 KB
#include <bits/stdc++.h>

int main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	
	int n, k, m; std::cin >> n >> k >> m;
	std::vector <int> a(n);
	for (int& x : a) std::cin >> x;
	std::vector <int> req(n, 0), has(n, 0);
	int cntgood = n;
	for (int i = 0; i < m; i++) {
		int t, h; std::cin >> t >> h;
		req[t] = h;
		cntgood--;
	}
	int ans = 1 << 30;
	for (int l = 0, r = 0; r < n; r++) {
		has[a[r]]++;
		if (has[a[r]] == req[a[r]]) cntgood++;
		while (cntgood == n && has[a[l]] > req[a[l]]) has[a[l++]]--;
		if (cntgood == n) ans = std::min(ans, r - l + 1);
	}
	if (ans == 1 << 30) std::cout << "impossible\n";
	else std::cout << ans << "\n";
	std::cout.flush();
	std::cin >> n;
	
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 3072 KB Output is correct
2 Correct 17 ms 3064 KB Output is correct
3 Correct 18 ms 3200 KB Output is correct
4 Correct 16 ms 3072 KB Output is correct
5 Correct 21 ms 3840 KB Output is correct
6 Correct 15 ms 3072 KB Output is correct
7 Correct 16 ms 3220 KB Output is correct
8 Correct 24 ms 3960 KB Output is correct
9 Correct 20 ms 3712 KB Output is correct
10 Correct 16 ms 3092 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 4472 KB Output is correct
2 Correct 30 ms 4344 KB Output is correct
3 Correct 25 ms 4096 KB Output is correct
4 Correct 17 ms 3072 KB Output is correct
5 Correct 36 ms 4856 KB Output is correct
6 Correct 39 ms 4864 KB Output is correct
7 Correct 20 ms 3712 KB Output is correct
8 Correct 24 ms 3968 KB Output is correct
9 Correct 15 ms 3072 KB Output is correct
10 Correct 17 ms 3072 KB Output is correct
11 Correct 17 ms 3200 KB Output is correct
12 Correct 16 ms 3072 KB Output is correct
13 Correct 22 ms 3840 KB Output is correct
14 Correct 15 ms 3072 KB Output is correct
15 Correct 16 ms 3328 KB Output is correct
16 Correct 23 ms 3968 KB Output is correct
17 Correct 20 ms 3712 KB Output is correct
18 Correct 16 ms 3072 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 0 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct