답안 #680502

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680502 2023-01-11T02:06:59 Z jhwest2 Martian DNA (BOI18_dna) C++17
100 / 100
237 ms 11748 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 202020;
int n, k, r, a[N];
map<int, int> mp;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(0);
    cin >> n >> k >> r;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 0; i < r; i++) {
        int x, y; cin >> x >> y;
        mp[x] = y;
    }  
    int cnt = r, ans = 1e9;
    for (int i = 1, j = 1; i <= n; i++) {
        while (j <= n && cnt) {
            if (--mp[a[j]] == 0)
                --cnt;
            ++j;
        }
        if (cnt == 0)
            ans = min(ans, j - i);
        
        if (++mp[a[i]] == 1)
            ++cnt;
    }
    if (ans == 1e9)
        cout << "impossible";
    else
        cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 328 KB Output is correct
9 Correct 0 ms 328 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 2 ms 468 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 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 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1420 KB Output is correct
2 Correct 15 ms 1492 KB Output is correct
3 Correct 16 ms 1492 KB Output is correct
4 Correct 14 ms 1492 KB Output is correct
5 Correct 116 ms 5996 KB Output is correct
6 Correct 17 ms 1416 KB Output is correct
7 Correct 27 ms 1672 KB Output is correct
8 Correct 234 ms 11748 KB Output is correct
9 Correct 56 ms 2312 KB Output is correct
10 Correct 17 ms 1508 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 2 ms 352 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 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 212 KB Output is correct
25 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 111 ms 6608 KB Output is correct
2 Correct 149 ms 5508 KB Output is correct
3 Correct 100 ms 5124 KB Output is correct
4 Correct 10 ms 1428 KB Output is correct
5 Correct 162 ms 7928 KB Output is correct
6 Correct 237 ms 11588 KB Output is correct
7 Correct 59 ms 2508 KB Output is correct
8 Correct 72 ms 3148 KB Output is correct
9 Correct 16 ms 1384 KB Output is correct
10 Correct 14 ms 1416 KB Output is correct
11 Correct 17 ms 1492 KB Output is correct
12 Correct 13 ms 1528 KB Output is correct
13 Correct 88 ms 6000 KB Output is correct
14 Correct 16 ms 1492 KB Output is correct
15 Correct 34 ms 1688 KB Output is correct
16 Correct 176 ms 11724 KB Output is correct
17 Correct 71 ms 2340 KB Output is correct
18 Correct 17 ms 1444 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 2 ms 356 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 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 212 KB Output is correct
29 Correct 0 ms 320 KB Output is correct
30 Correct 0 ms 332 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 328 KB Output is correct