답안 #476410

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
476410 2021-09-26T11:35:08 Z AdamGS Martian DNA (BOI18_dna) C++14
100 / 100
38 ms 6736 KB
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=2e5+7;
int T[LIM], ile[LIM], R[LIM];
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, k, r;
	cin >> n >> k >> r;
	rep(i, n) cin >> T[i];
	int zle=0;
	rep(i, r) {
		int b, q;
		cin >> b >> q;
		R[b]=q;
		if(q) ++zle;
	}
	int l=0, ans=LIM;
	rep(i, n) {
		while(l<n && zle) {
			++ile[T[l]];
			if(ile[T[l]]==R[T[l]]) --zle;
			++l;
		}
		if(!zle) ans=min(ans, l-i);
		if(ile[T[i]]==R[T[i]]) ++zle;
		--ile[T[i]];
	}
	if(ans==LIM) cout << "impossible\n";
	else cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 2268 KB Output is correct
2 Correct 16 ms 2232 KB Output is correct
3 Correct 16 ms 2252 KB Output is correct
4 Correct 16 ms 2252 KB Output is correct
5 Correct 20 ms 3660 KB Output is correct
6 Correct 17 ms 2296 KB Output is correct
7 Correct 18 ms 2476 KB Output is correct
8 Correct 24 ms 4684 KB Output is correct
9 Correct 22 ms 2844 KB Output is correct
10 Correct 14 ms 2268 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 4880 KB Output is correct
2 Correct 28 ms 4428 KB Output is correct
3 Correct 23 ms 4072 KB Output is correct
4 Correct 12 ms 2244 KB Output is correct
5 Correct 38 ms 5488 KB Output is correct
6 Correct 37 ms 6736 KB Output is correct
7 Correct 20 ms 2892 KB Output is correct
8 Correct 25 ms 3336 KB Output is correct
9 Correct 13 ms 2252 KB Output is correct
10 Correct 13 ms 2256 KB Output is correct
11 Correct 18 ms 2240 KB Output is correct
12 Correct 13 ms 2312 KB Output is correct
13 Correct 18 ms 3692 KB Output is correct
14 Correct 14 ms 2292 KB Output is correct
15 Correct 14 ms 2476 KB Output is correct
16 Correct 22 ms 4688 KB Output is correct
17 Correct 17 ms 2904 KB Output is correct
18 Correct 13 ms 2252 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct