답안 #647092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
647092 2022-10-01T14:49:29 Z tvladm2009 Martian DNA (BOI18_dna) C++14
0 / 100
34 ms 4588 KB
#include <bits/stdc++.h>

using ll = long long;

int const nmax = 200000;

int v[1 + nmax], mn[1 + nmax], fr[1 + nmax];

int main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);

  int n, k, r;
  std::cin >> n >> k >> r;
  for(int i = 1;i <= n; i++)
    std::cin >> v[i];
  for(int i = 1;i <= r; i++) {
    int x, y;
    std::cin >> x >> y;
    mn[x] = y;
  }

  int j = 1, cnt = 0;
  while(j <= n && cnt != r) {
    fr[v[j]]++;
    if(fr[v[j]] == mn[v[j]])
      cnt++;
    j++;
  }
  if(j == n + 1) {
    std::cout << "impossible";
    return 0;
  }
  int ans = j - 1;
  for(int i = 2;i <= n; i++) {
    fr[v[i - 1]]--;
    if(fr[v[i - 1]] < mn[v[i - 1]])
      cnt--;
    while(j <= n && cnt != r) {
      fr[v[j]]++;
      if(fr[v[j]] == mn[v[j]])
        cnt++;
      j++;
    }
    if(j == n + 1)
      break;
    ans = std::min(ans, j - i);
  }
  std::cout << ans;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 336 KB Output is correct
6 Correct 1 ms 412 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Incorrect 0 ms 340 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1448 KB Output is correct
2 Correct 17 ms 1436 KB Output is correct
3 Correct 17 ms 1440 KB Output is correct
4 Correct 12 ms 1488 KB Output is correct
5 Correct 16 ms 2504 KB Output is correct
6 Incorrect 11 ms 1504 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 3412 KB Output is correct
2 Correct 25 ms 3148 KB Output is correct
3 Correct 21 ms 2856 KB Output is correct
4 Correct 12 ms 1492 KB Output is correct
5 Correct 32 ms 4032 KB Output is correct
6 Correct 34 ms 4588 KB Output is correct
7 Correct 16 ms 2068 KB Output is correct
8 Correct 18 ms 2436 KB Output is correct
9 Correct 12 ms 1492 KB Output is correct
10 Correct 12 ms 1456 KB Output is correct
11 Correct 18 ms 1488 KB Output is correct
12 Correct 13 ms 1492 KB Output is correct
13 Correct 19 ms 2508 KB Output is correct
14 Incorrect 11 ms 1412 KB Output isn't correct
15 Halted 0 ms 0 KB -