| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1298134 | lmquan | Martian DNA (BOI18_dna) | C++20 | 23 ms | 3020 KiB |
#define taskname ""
#include <bits/stdc++.h>
using namespace std;
int main() {
if (fopen(taskname".inp", "r")) {
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, k, r;
cin >> n >> k >> r;
vector<int> d(n + 1);
for (int i = 1; i <= n; i++) {
cin >> d[i];
}
vector<int> e(k);
for (int i = 1; i <= r; i++) {
int b, q;
cin >> b >> q;
e[b] = q;
}
vector<int> a(k, 0);
int j = 0, t = r, result = n + 1;
for (int i = 1; i <= n; i++) {
while (t > 0 && j < n) {
int x = d[++j];
a[x]++;
if (a[x] == e[x]) {
t--;
}
}
if (t == 0) {
result = min(result, j - i + 1);
a[d[i]]--;
if (a[d[i]] == e[d[i]] - 1) {
t++;
}
} else {
break;
}
}
if (result > n) {
cout << "impossible";
} else {
cout << result;
}
return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
