답안 #643401

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
643401 2022-09-22T01:51:16 Z andecaandeci Martian DNA (BOI18_dna) C++17
100 / 100
28 ms 2772 KB
#include <bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, k, r; cin >> n >> k >> r;
    vector<int>a(n + 1), req(n + 1), freq(n + 1);
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= r; i++){
        int x, y; cin >> x >> y;
        req[x] = y;
    }

    int ans = 1e9;
    int left = 1, right = 0;
    int ok = 0;

    while(left <= n && right <= n){
        while(right + 1 <= n && ok != r){
            freq[a[right + 1]]++;
            if(freq[a[right + 1]] == req[a[right + 1]]) ok++;
            right++;
        }

        if(ok != r) break;
        ans = min(ans, right - left + 1);
        freq[a[left]]--;
        if(freq[a[left]] < req[a[left]]) ok--;
        left++;
    }   

    if(ans == 1e9) cout << "impossible" << '\n';
    else cout << ans << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 0 ms 212 KB Output is correct
7 Correct 0 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 0 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 0 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 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 2644 KB Output is correct
2 Correct 11 ms 2644 KB Output is correct
3 Correct 13 ms 2692 KB Output is correct
4 Correct 11 ms 2644 KB Output is correct
5 Correct 15 ms 2644 KB Output is correct
6 Correct 10 ms 2644 KB Output is correct
7 Correct 11 ms 2644 KB Output is correct
8 Correct 21 ms 2688 KB Output is correct
9 Correct 14 ms 2644 KB Output is correct
10 Correct 15 ms 2772 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 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 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 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 2668 KB Output is correct
2 Correct 22 ms 2644 KB Output is correct
3 Correct 18 ms 2692 KB Output is correct
4 Correct 12 ms 2644 KB Output is correct
5 Correct 27 ms 2644 KB Output is correct
6 Correct 28 ms 2644 KB Output is correct
7 Correct 16 ms 2644 KB Output is correct
8 Correct 17 ms 2688 KB Output is correct
9 Correct 11 ms 2644 KB Output is correct
10 Correct 11 ms 2644 KB Output is correct
11 Correct 12 ms 2644 KB Output is correct
12 Correct 12 ms 2692 KB Output is correct
13 Correct 15 ms 2644 KB Output is correct
14 Correct 10 ms 2644 KB Output is correct
15 Correct 12 ms 2644 KB Output is correct
16 Correct 18 ms 2644 KB Output is correct
17 Correct 16 ms 2644 KB Output is correct
18 Correct 11 ms 2644 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 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct