답안 #1093135

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1093135 2024-09-26T02:35:24 Z juicy Martian DNA (BOI18_dna) C++17
100 / 100
149 ms 143300 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int N = 2e5, inf = 1e9;

int n, k, r;
int a[N], l[N];
deque<int> dq[N];

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  cin >> n >> k >> r;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < r; ++i) {
    int b; cin >> b >> l[b];
  }
  set<int> st;
  int res = inf;
  for (int i = 0; i < n; ++i) {
    if (l[a[i]]) {
      dq[a[i]].push_back(i);
      if (dq[a[i]].size() > l[a[i]]) {
        st.erase(dq[a[i]].front());
        dq[a[i]].pop_front();
      }
      if (dq[a[i]].size() == l[a[i]]) {
        st.insert(dq[a[i]].front());
      }
    }
    if (st.size() == r) {
      res = min(res, i - *st.begin() + 1);
    }
  }  
  if (res == inf) {
    cout << "impossible";
  } else {
    cout << res;
  }
  return 0;
}

Compilation message

dna.cpp: In function 'int main()':
dna.cpp:32:27: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |       if (dq[a[i]].size() > l[a[i]]) {
      |           ~~~~~~~~~~~~~~~~^~~~~~~~~
dna.cpp:36:27: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |       if (dq[a[i]].size() == l[a[i]]) {
      |           ~~~~~~~~~~~~~~~~^~~~~~~~~~
dna.cpp:40:19: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |     if (st.size() == r) {
      |         ~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 134884 KB Output is correct
2 Correct 63 ms 135004 KB Output is correct
3 Correct 63 ms 134888 KB Output is correct
4 Correct 66 ms 134992 KB Output is correct
5 Correct 62 ms 134992 KB Output is correct
6 Correct 71 ms 134992 KB Output is correct
7 Correct 66 ms 134996 KB Output is correct
8 Correct 68 ms 135028 KB Output is correct
9 Correct 64 ms 135080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 134992 KB Output is correct
2 Correct 75 ms 134908 KB Output is correct
3 Correct 66 ms 134996 KB Output is correct
4 Correct 60 ms 134996 KB Output is correct
5 Correct 61 ms 135012 KB Output is correct
6 Correct 57 ms 135112 KB Output is correct
7 Correct 59 ms 134996 KB Output is correct
8 Correct 81 ms 134996 KB Output is correct
9 Correct 60 ms 134992 KB Output is correct
10 Correct 60 ms 135016 KB Output is correct
11 Correct 67 ms 134992 KB Output is correct
12 Correct 62 ms 134996 KB Output is correct
13 Correct 65 ms 134992 KB Output is correct
14 Correct 68 ms 134996 KB Output is correct
15 Correct 61 ms 134884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 136528 KB Output is correct
2 Correct 87 ms 136528 KB Output is correct
3 Correct 74 ms 136136 KB Output is correct
4 Correct 83 ms 136332 KB Output is correct
5 Correct 72 ms 136880 KB Output is correct
6 Correct 77 ms 137056 KB Output is correct
7 Correct 84 ms 136272 KB Output is correct
8 Correct 76 ms 137048 KB Output is correct
9 Correct 74 ms 136656 KB Output is correct
10 Correct 84 ms 136560 KB Output is correct
11 Correct 60 ms 134996 KB Output is correct
12 Correct 75 ms 134992 KB Output is correct
13 Correct 64 ms 134996 KB Output is correct
14 Correct 65 ms 134992 KB Output is correct
15 Correct 58 ms 134996 KB Output is correct
16 Correct 68 ms 134992 KB Output is correct
17 Correct 68 ms 134992 KB Output is correct
18 Correct 65 ms 135000 KB Output is correct
19 Correct 63 ms 135096 KB Output is correct
20 Correct 63 ms 134996 KB Output is correct
21 Correct 64 ms 135016 KB Output is correct
22 Correct 69 ms 134992 KB Output is correct
23 Correct 65 ms 134996 KB Output is correct
24 Correct 65 ms 134992 KB Output is correct
25 Correct 65 ms 134996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 149 ms 141652 KB Output is correct
2 Correct 126 ms 140368 KB Output is correct
3 Correct 91 ms 138320 KB Output is correct
4 Correct 80 ms 136020 KB Output is correct
5 Correct 115 ms 138328 KB Output is correct
6 Correct 128 ms 143300 KB Output is correct
7 Correct 103 ms 137172 KB Output is correct
8 Correct 112 ms 137856 KB Output is correct
9 Correct 81 ms 136532 KB Output is correct
10 Correct 77 ms 136280 KB Output is correct
11 Correct 84 ms 136276 KB Output is correct
12 Correct 82 ms 136532 KB Output is correct
13 Correct 71 ms 137044 KB Output is correct
14 Correct 76 ms 137096 KB Output is correct
15 Correct 77 ms 136276 KB Output is correct
16 Correct 77 ms 137044 KB Output is correct
17 Correct 70 ms 136784 KB Output is correct
18 Correct 84 ms 136528 KB Output is correct
19 Correct 64 ms 134992 KB Output is correct
20 Correct 66 ms 134916 KB Output is correct
21 Correct 69 ms 135028 KB Output is correct
22 Correct 64 ms 134992 KB Output is correct
23 Correct 66 ms 134996 KB Output is correct
24 Correct 65 ms 135020 KB Output is correct
25 Correct 71 ms 134996 KB Output is correct
26 Correct 62 ms 134992 KB Output is correct
27 Correct 62 ms 134996 KB Output is correct
28 Correct 60 ms 134996 KB Output is correct
29 Correct 64 ms 134928 KB Output is correct
30 Correct 63 ms 135088 KB Output is correct
31 Correct 67 ms 135004 KB Output is correct
32 Correct 89 ms 135096 KB Output is correct
33 Correct 82 ms 134856 KB Output is correct