답안 #759019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
759019 2023-06-15T16:55:50 Z ymm Martian DNA (BOI18_dna) C++17
100 / 100
25 ms 3792 KB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

const int N = 200'010;
int a[N], cnt[N];
int n, k, r;

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	cin >> n >> k >> r;
	Loop (i,0,n)
		cin >> a[i];
	Loop (i,0,r) {
		int b, q;
		cin >> b >> q;
		cnt[b] = q;
	}
	int ans = n+1;
	int p = 0;
	int pos = r;
	Loop (i,0,n) {
		while (pos) {
			if (p == n)
				goto end;
			cnt[a[p]]--;
			pos -= cnt[a[p]] == 0;
			++p;
		}
		ans = min<int>(ans, p - i);
		pos += cnt[a[i]] == 0;
		cnt[a[i]]++;
	}
end:
	if (ans == n+1)
		cout << "impossible\n";
	else
		cout << ans << '\n';
}
# 결과 실행 시간 메모리 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
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 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 340 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 340 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 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 212 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 14 ms 1436 KB Output is correct
2 Correct 9 ms 1492 KB Output is correct
3 Correct 10 ms 1492 KB Output is correct
4 Correct 9 ms 1492 KB Output is correct
5 Correct 13 ms 2568 KB Output is correct
6 Correct 12 ms 1420 KB Output is correct
7 Correct 9 ms 1588 KB Output is correct
8 Correct 22 ms 3144 KB Output is correct
9 Correct 12 ms 2040 KB Output is correct
10 Correct 9 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 1 ms 332 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 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 3188 KB Output is correct
2 Correct 19 ms 2880 KB Output is correct
3 Correct 21 ms 2656 KB Output is correct
4 Correct 9 ms 1452 KB Output is correct
5 Correct 22 ms 3680 KB Output is correct
6 Correct 25 ms 3792 KB Output is correct
7 Correct 13 ms 2132 KB Output is correct
8 Correct 16 ms 2232 KB Output is correct
9 Correct 11 ms 1480 KB Output is correct
10 Correct 10 ms 1420 KB Output is correct
11 Correct 10 ms 1492 KB Output is correct
12 Correct 9 ms 1492 KB Output is correct
13 Correct 13 ms 2496 KB Output is correct
14 Correct 9 ms 1500 KB Output is correct
15 Correct 9 ms 1672 KB Output is correct
16 Correct 16 ms 3120 KB Output is correct
17 Correct 13 ms 2116 KB Output is correct
18 Correct 14 ms 1452 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 288 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 324 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 296 KB Output is correct