답안 #660149

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
660149 2022-11-20T14:00:15 Z mariaclara Martian DNA (BOI18_dna) C++17
68 / 100
2000 ms 12432 KB
#include <bits/stdc++.h>
 
using namespace std;

const int MAXN = 2e5+10;
typedef pair<int,int> pii;
#define pb push_back
#define f first
#define s second

int n, k, r, a, b, resp = MAXN;
vector<int> num[MAXN];
vector<pii> query;
int main () {
   cin >> n >> k >> r;

   for(int i = 1; i <= n; i++) {
      cin >> a;
      num[a].pb(i);
   }

   while(r--) {
      cin >> a >> b;
      query.pb({a, b});
   }

   for(int i = 1; i <= n; i++) {
      int fim = 0;
      for(auto it : query) {
         auto ptr = lower_bound(num[it.f].begin(), num[it.f].end(), i);
         ptr += it.s - 1;
         if(ptr>=num[it.f].end()) { fim = -1; break; } 
         fim = max(fim, *ptr);
      }
      if(fim==-1) break;
      resp = min(resp, fim-i+1);
   }

   if(resp == MAXN) cout << "impossible\n";
   else cout << resp << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 5000 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 4 ms 4948 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 4 ms 5008 KB Output is correct
3 Correct 5 ms 5076 KB Output is correct
4 Correct 4 ms 5136 KB Output is correct
5 Correct 4 ms 5004 KB Output is correct
6 Correct 5 ms 5008 KB Output is correct
7 Correct 3 ms 4992 KB Output is correct
8 Correct 3 ms 4996 KB Output is correct
9 Correct 3 ms 5000 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 2 ms 5000 KB Output is correct
12 Correct 3 ms 4948 KB Output is correct
13 Correct 3 ms 4996 KB Output is correct
14 Correct 3 ms 5004 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 6676 KB Output is correct
2 Correct 46 ms 6684 KB Output is correct
3 Correct 73 ms 6432 KB Output is correct
4 Correct 55 ms 6692 KB Output is correct
5 Correct 74 ms 8700 KB Output is correct
6 Correct 30 ms 6472 KB Output is correct
7 Correct 44 ms 6472 KB Output is correct
8 Correct 92 ms 12432 KB Output is correct
9 Correct 62 ms 7304 KB Output is correct
10 Correct 74 ms 6576 KB Output is correct
11 Correct 4 ms 4948 KB Output is correct
12 Correct 3 ms 5008 KB Output is correct
13 Correct 5 ms 5096 KB Output is correct
14 Correct 5 ms 5136 KB Output is correct
15 Correct 4 ms 5008 KB Output is correct
16 Correct 5 ms 5004 KB Output is correct
17 Correct 3 ms 5000 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 3 ms 5000 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 3 ms 5000 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2082 ms 10340 KB Time limit exceeded
2 Halted 0 ms 0 KB -