답안 #554563

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
554563 2022-04-28T18:33:37 Z Soumya1 Martian DNA (BOI18_dna) C++17
100 / 100
34 ms 3788 KB
#include <bits/stdc++.h>
#ifdef __LOCAL__
#include <debug_local.h>
#endif
using namespace std;
const int mxN = 2e5 + 5;
int a[mxN];
int cnt[mxN];
void testCase() {
  int n, k, r;
  cin >> n >> k >> r;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < r; i++) {
    int a, b;
    cin >> a >> b;
    cnt[a] = b;
  }
  int cc = r;
  int ptr = 1;
  int ans = n + 1;
  for (int i = 1; i <= n; i++) {
    while (ptr <= n && cc) {
      cnt[a[ptr]]--;
      if (cnt[a[ptr]] == 0) cc--;
      ptr++;
    }
    if (!cc) ans = min(ans, ptr - i);
    cnt[a[i]]++;
    if (cnt[a[i]] == 1) cc++;
  }
  if (ans == n + 1) cout << "impossible\n";
  else cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  testCase();
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 340 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 348 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 344 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 0 ms 328 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 332 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 332 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1424 KB Output is correct
2 Correct 13 ms 1488 KB Output is correct
3 Correct 13 ms 1528 KB Output is correct
4 Correct 12 ms 1496 KB Output is correct
5 Correct 17 ms 2508 KB Output is correct
6 Correct 15 ms 1492 KB Output is correct
7 Correct 13 ms 1688 KB Output is correct
8 Correct 19 ms 3136 KB Output is correct
9 Correct 15 ms 1976 KB Output is correct
10 Correct 12 ms 1496 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 468 KB Output is correct
14 Correct 1 ms 368 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 3148 KB Output is correct
2 Correct 24 ms 2828 KB Output is correct
3 Correct 19 ms 2512 KB Output is correct
4 Correct 11 ms 1420 KB Output is correct
5 Correct 30 ms 3532 KB Output is correct
6 Correct 34 ms 3788 KB Output is correct
7 Correct 16 ms 2076 KB Output is correct
8 Correct 19 ms 2380 KB Output is correct
9 Correct 11 ms 1492 KB Output is correct
10 Correct 12 ms 1496 KB Output is correct
11 Correct 13 ms 1488 KB Output is correct
12 Correct 12 ms 1476 KB Output is correct
13 Correct 17 ms 2516 KB Output is correct
14 Correct 12 ms 1512 KB Output is correct
15 Correct 12 ms 1660 KB Output is correct
16 Correct 21 ms 3060 KB Output is correct
17 Correct 15 ms 2004 KB Output is correct
18 Correct 12 ms 1492 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 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 328 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 328 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct