Submission #1093847

# Submission time Handle Problem Language Result Execution time Memory
1093847 2024-09-27T16:29:10 Z josiftepe Martian DNA (BOI18_dna) C++14
100 / 100
63 ms 3920 KB
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
    int n, k, m;
    cin >> n >> k >> m;
    
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    vector<int> req(k + 1, 0);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        req[a] = b;
    }
    
    int j = 0;
    int cnt = m;
    int res = 2e9;
    for(int i = 0; i < n; i++) {
        while(cnt > 0 and j < n) {
            req[v[j]]--;
            if(req[v[j]] == 0) {
                cnt--;
            }
            j++;
        }
        if(cnt == 0) {
            res = min(res, j - i);
        }
        req[v[i]]++;
        if(req[v[i]] > 0) {
            cnt++;
        }
    }
    if(res == 2e9) {
        cout << "impossible" << endl;
    }
    else {
        cout << res << endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 436 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1624 KB Output is correct
2 Correct 19 ms 1596 KB Output is correct
3 Correct 19 ms 1628 KB Output is correct
4 Correct 18 ms 1592 KB Output is correct
5 Correct 33 ms 2644 KB Output is correct
6 Correct 18 ms 1368 KB Output is correct
7 Correct 20 ms 1628 KB Output is correct
8 Correct 34 ms 3156 KB Output is correct
9 Correct 29 ms 2140 KB Output is correct
10 Correct 18 ms 1620 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 3156 KB Output is correct
2 Correct 45 ms 2908 KB Output is correct
3 Correct 38 ms 2736 KB Output is correct
4 Correct 18 ms 1372 KB Output is correct
5 Correct 58 ms 3516 KB Output is correct
6 Correct 59 ms 3920 KB Output is correct
7 Correct 29 ms 2128 KB Output is correct
8 Correct 34 ms 2384 KB Output is correct
9 Correct 19 ms 1372 KB Output is correct
10 Correct 18 ms 1600 KB Output is correct
11 Correct 19 ms 1628 KB Output is correct
12 Correct 17 ms 1452 KB Output is correct
13 Correct 30 ms 2652 KB Output is correct
14 Correct 17 ms 1372 KB Output is correct
15 Correct 20 ms 1600 KB Output is correct
16 Correct 34 ms 3160 KB Output is correct
17 Correct 27 ms 1972 KB Output is correct
18 Correct 17 ms 1628 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 436 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 436 KB Output is correct