# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
544736 | rainboy | Martian DNA (BOI18_dna) | C11 | 37 ms | 3724 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#define N 200000
int min(int a, int b) { return a < b ? a : b; }
int main() {
static int aa[N], kk[N];
int n, k, r, i, j, ans;
scanf("%d%d%d", &n, &k, &r);
for (i = 0; i < n; i++)
scanf("%d", &aa[i]);
for (i = 0; i < r; i++) {
int a;
scanf("%d%d", &a, &k);
kk[a] = k;
}
ans = n + 1;
for (i = 0, j = 0; j < n; j++) {
if (--kk[aa[j]] == 0)
r--;
while (kk[aa[i]] < 0)
kk[aa[i++]]++;
if (r == 0)
ans = min(ans, j - i + 1);
}
if (ans == n + 1)
printf("impossible\n");
else
printf("%d\n", ans);
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... |