Submission #1116921

# Submission time Handle Problem Language Result Execution time Memory
1116921 2024-11-22T14:53:02 Z njoop Martian DNA (BOI18_dna) C++17
100 / 100
24 ms 3532 KB
#include <bits/stdc++.h>
 
using namespace std;
 
int n, k, r, req[300010], amt[300010], qu, ans = 1e9, p1 = 0, p2 = 0;
vector<int> dna;

void add(int type) {
    if(req[type] == 0) return;
    if(req[type] == amt[type]+1) {
        qu++;
    }
    amt[type]++;
}
 
void del(int type) {
    if(req[type] == 0) return;
    if(req[type] == amt[type]) {
        qu--;
    }
    amt[type]--;
}
 
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> k >> r;
    for(int i=1; i<=n; i++) {
        int in;
        cin >> in;
        dna.push_back(in);
    }
    for(int i=1; i<=r; i++) {
        int b, q;
        cin >> b >> q;
        req[b] = q;
    }
    while(p1 < n) {
        while(qu < r && p2 < n) {
            add(dna[p2]);
            p2++;
        }
        if(qu == r) {
            ans = min(ans, p2-p1);
        }
        del(dna[p1]);
        p1++;
    }
    if(ans == 1e9) {
        cout << "impossible";
    } else {
        cout << ans;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 2 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 2 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2552 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 2 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2484 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2552 KB Output is correct
13 Correct 1 ms 2520 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 3276 KB Output is correct
2 Correct 11 ms 3528 KB Output is correct
3 Correct 10 ms 3276 KB Output is correct
4 Correct 10 ms 3276 KB Output is correct
5 Correct 12 ms 3276 KB Output is correct
6 Correct 10 ms 3444 KB Output is correct
7 Correct 10 ms 3224 KB Output is correct
8 Correct 13 ms 3276 KB Output is correct
9 Correct 11 ms 3276 KB Output is correct
10 Correct 10 ms 3276 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2552 KB Output is correct
16 Correct 2 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 2 ms 2384 KB Output is correct
23 Correct 2 ms 2384 KB Output is correct
24 Correct 2 ms 2552 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3532 KB Output is correct
2 Correct 20 ms 3532 KB Output is correct
3 Correct 19 ms 3532 KB Output is correct
4 Correct 10 ms 3276 KB Output is correct
5 Correct 24 ms 3532 KB Output is correct
6 Correct 23 ms 3532 KB Output is correct
7 Correct 17 ms 3276 KB Output is correct
8 Correct 15 ms 3276 KB Output is correct
9 Correct 11 ms 3276 KB Output is correct
10 Correct 11 ms 3276 KB Output is correct
11 Correct 12 ms 3328 KB Output is correct
12 Correct 11 ms 3276 KB Output is correct
13 Correct 16 ms 3276 KB Output is correct
14 Correct 10 ms 3276 KB Output is correct
15 Correct 11 ms 3276 KB Output is correct
16 Correct 13 ms 3328 KB Output is correct
17 Correct 15 ms 3276 KB Output is correct
18 Correct 14 ms 3276 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 2 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 1 ms 2384 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 1 ms 2384 KB Output is correct
28 Correct 1 ms 2384 KB Output is correct
29 Correct 1 ms 2516 KB Output is correct
30 Correct 1 ms 2384 KB Output is correct
31 Correct 1 ms 2384 KB Output is correct
32 Correct 2 ms 2384 KB Output is correct
33 Correct 2 ms 2384 KB Output is correct