# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
703049 | 2023-02-25T19:21:04 Z | Ronin13 | Martian DNA (BOI18_dna) | C++14 | 73 ms | 14104 KB |
#include <bits/stdc++.h> #define ll long long #define f first #define s second #define pii pair<int,int> #define pll pair<ll,ll> #define pb push_back #define epb emplace_back using namespace std; const int nmax = 2000001; ll dp[nmax][32]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n, k, r; cin >> n >> k >> r; vector <vector <int> > vec(k + 1); int a[n + 1]; for(int i = 1; i <= n; i++){ cin >> a[i]; vec[a[i]].pb(i); } vector <int> ind(k + 1, -1); int mx = 0; for(int i = 1; i <= r; i++){ int b, q; cin >> b >> q; ind[b] = q - 1; if(vec[b].size() <= ind[b]){ cout << "impossible\n"; return 0; } mx = max(mx, vec[b][q - 1]); } int ans = 1e9; for(int i = 1; i <= n; i++){ ans = min(ans, mx - i + 1); if(ind[a[i]] != -1){ ind[a[i]]++; if(ind[a[i]] == vec[a[i]].size()) break; mx = max(mx, vec[a[i]][ind[a[i]]]); } } cout << ans; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 324 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 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 | 0 ms | 212 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 | 468 KB | Output is correct |
4 | Correct | 1 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 328 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 2744 KB | Output is correct |
2 | Correct | 16 ms | 2704 KB | Output is correct |
3 | Correct | 12 ms | 2544 KB | Output is correct |
4 | Correct | 12 ms | 2772 KB | Output is correct |
5 | Correct | 28 ms | 6988 KB | Output is correct |
6 | Correct | 11 ms | 2644 KB | Output is correct |
7 | Correct | 13 ms | 2600 KB | Output is correct |
8 | Correct | 52 ms | 14008 KB | Output is correct |
9 | Correct | 21 ms | 3596 KB | Output is correct |
10 | Correct | 12 ms | 2612 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 | 504 KB | Output is correct |
15 | Correct | 1 ms | 444 KB | Output is correct |
16 | Correct | 1 ms | 340 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 | 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 | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 328 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 73 ms | 7452 KB | Output is correct |
2 | Correct | 42 ms | 6324 KB | Output is correct |
3 | Correct | 29 ms | 6092 KB | Output is correct |
4 | Correct | 13 ms | 2672 KB | Output is correct |
5 | Correct | 32 ms | 8276 KB | Output is correct |
6 | Correct | 62 ms | 13640 KB | Output is correct |
7 | Correct | 22 ms | 3568 KB | Output is correct |
8 | Correct | 29 ms | 4436 KB | Output is correct |
9 | Correct | 11 ms | 2772 KB | Output is correct |
10 | Correct | 12 ms | 2720 KB | Output is correct |
11 | Correct | 13 ms | 2524 KB | Output is correct |
12 | Correct | 12 ms | 2820 KB | Output is correct |
13 | Correct | 26 ms | 7080 KB | Output is correct |
14 | Correct | 11 ms | 2732 KB | Output is correct |
15 | Correct | 12 ms | 2640 KB | Output is correct |
16 | Correct | 43 ms | 14104 KB | Output is correct |
17 | Correct | 20 ms | 3592 KB | Output is correct |
18 | Correct | 11 ms | 2596 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 | 468 KB | Output is correct |
22 | Correct | 1 ms | 596 KB | Output is correct |
23 | Correct | 1 ms | 340 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 | 212 KB | Output is correct |
27 | Correct | 0 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 324 KB | Output is correct |
29 | Correct | 1 ms | 332 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 0 ms | 212 KB | Output is correct |