답안 #696193

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
696193 2023-02-05T19:32:31 Z bdl Martian DNA (BOI18_dna) C++17
100 / 100
32 ms 4484 KB
#include <iostream>
using namespace std;

const int N = 2e5;

namespace ds {
  int c[N], g[N], z;

  void add(int x) {
    if (g[x] > 0)
      z -= ++c[x] == g[x];
  }
  void rem(int x) {
    if (g[x] > 0)
      z += c[x]-- == g[x];
  }
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n, k, m;
  cin >> n >> k >> m;
  static int a[N];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int h = 0; h < m; h++) {
    int i;
    cin >> i;
    cin >> ds::g[i];
  }
  ds::z = m;
  int x = n + 1;
  for (int i = 0, j = 0; i < n; i++) {
    while (j < n && ds::z > 0)
      ds::add(a[j++]);
    if (ds::z == 0)
      x = min(x, j - i);
    ds::rem(a[i]);
  }
  if (x == n + 1)
    cout << "impossible\n";
  else
    cout << x << '\n';
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 324 KB Output is correct
9 Correct 0 ms 328 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1492 KB Output is correct
2 Correct 13 ms 1468 KB Output is correct
3 Correct 14 ms 1536 KB Output is correct
4 Correct 13 ms 1524 KB Output is correct
5 Correct 16 ms 2252 KB Output is correct
6 Correct 12 ms 1488 KB Output is correct
7 Correct 13 ms 1648 KB Output is correct
8 Correct 18 ms 2368 KB Output is correct
9 Correct 14 ms 2024 KB Output is correct
10 Correct 12 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 344 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 332 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 324 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 3384 KB Output is correct
2 Correct 24 ms 3148 KB Output is correct
3 Correct 20 ms 2784 KB Output is correct
4 Correct 14 ms 1424 KB Output is correct
5 Correct 30 ms 3940 KB Output is correct
6 Correct 32 ms 4484 KB Output is correct
7 Correct 17 ms 2132 KB Output is correct
8 Correct 19 ms 2380 KB Output is correct
9 Correct 12 ms 1492 KB Output is correct
10 Correct 13 ms 1428 KB Output is correct
11 Correct 13 ms 1544 KB Output is correct
12 Correct 14 ms 1416 KB Output is correct
13 Correct 15 ms 2260 KB Output is correct
14 Correct 12 ms 1492 KB Output is correct
15 Correct 13 ms 1672 KB Output is correct
16 Correct 17 ms 2388 KB Output is correct
17 Correct 14 ms 1980 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 344 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 324 KB Output is correct
31 Correct 0 ms 328 KB Output is correct
32 Correct 0 ms 324 KB Output is correct
33 Correct 0 ms 340 KB Output is correct