답안 #658887

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
658887 2022-11-15T10:51:51 Z Sohsoh84 Martian DNA (BOI18_dna) C++17
100 / 100
34 ms 3884 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define all(x)			(x).begin(),(x).end()
#define X			first
#define Y			second
#define sep			' '
#define endl			'\n'
#define debug(x)		cerr << #x << ": " <<  x << endl;

const ll MAXN = 1e6 + 10;

int R[MAXN], n, k, r, ans = MAXN, A[MAXN];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k >> r;
	for (int i = 1; i <= n; i++) cin >> A[i];

	for (int i = 1; i <= r; i++) {
		int x, y;
		cin >> x >> y;
		R[x] = y;
	}

	int p = 1;
	for (int i = 1; i <= n; i++) {
		if (R[A[i]] == 1) r--;
		R[A[i]]--;

		while (R[A[p]] < 0)
			R[A[p++]]++;

		if (r <= 0) ans = min(ans, i - p + 1);
	}

	cout << (ans == MAXN ? "impossible" : to_string(ans)) << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1480 KB Output is correct
2 Correct 12 ms 1428 KB Output is correct
3 Correct 12 ms 1520 KB Output is correct
4 Correct 14 ms 1448 KB Output is correct
5 Correct 16 ms 2512 KB Output is correct
6 Correct 10 ms 1488 KB Output is correct
7 Correct 15 ms 1620 KB Output is correct
8 Correct 17 ms 3060 KB Output is correct
9 Correct 14 ms 2000 KB Output is correct
10 Correct 11 ms 1492 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 324 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 3116 KB Output is correct
2 Correct 25 ms 2876 KB Output is correct
3 Correct 19 ms 2604 KB Output is correct
4 Correct 10 ms 1436 KB Output is correct
5 Correct 27 ms 3652 KB Output is correct
6 Correct 34 ms 3884 KB Output is correct
7 Correct 15 ms 2116 KB Output is correct
8 Correct 18 ms 2364 KB Output is correct
9 Correct 10 ms 1484 KB Output is correct
10 Correct 11 ms 1496 KB Output is correct
11 Correct 12 ms 1552 KB Output is correct
12 Correct 12 ms 1492 KB Output is correct
13 Correct 15 ms 2528 KB Output is correct
14 Correct 10 ms 1484 KB Output is correct
15 Correct 11 ms 1620 KB Output is correct
16 Correct 18 ms 3092 KB Output is correct
17 Correct 15 ms 1988 KB Output is correct
18 Correct 10 ms 1424 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 328 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 340 KB Output is correct