Submission #1115892

# Submission time Handle Problem Language Result Execution time Memory
1115892 2024-11-21T03:39:17 Z njoop Martian DNA (BOI18_dna) C++17
0 / 100
22 ms 4196 KB
#include <bits/stdc++.h>

using namespace std;

int n, k, r, req[100010], amt[100010], 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(p2 < n) {
        if(qu == r) {
            ans = min(ans, p2-p1);
            del(dna[p1]);
            p1++;
        } else {
            add(dna[p2]);
            p2++;
        }
    }
    if(ans == 1e9) {
        cout << "impossible";
    } else {
        cout << ans;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 484 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 504 KB Output is correct
9 Incorrect 1 ms 336 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2000 KB Output is correct
2 Correct 12 ms 1912 KB Output is correct
3 Correct 11 ms 2000 KB Output is correct
4 Correct 12 ms 2172 KB Output is correct
5 Correct 14 ms 2540 KB Output is correct
6 Incorrect 10 ms 2000 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 3524 KB Output is correct
2 Correct 18 ms 3276 KB Output is correct
3 Correct 15 ms 3020 KB Output is correct
4 Correct 9 ms 2000 KB Output is correct
5 Correct 21 ms 4196 KB Output is correct
6 Runtime error 15 ms 4016 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -