Submission #544736

#TimeUsernameProblemLanguageResultExecution timeMemory
544736rainboy Martian DNA (BOI18_dna)C11
100 / 100
37 ms3724 KiB
#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)

dna.c: In function 'main':
dna.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d%d%d", &n, &k, &r);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
dna.c:13:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
dna.c:17:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d%d", &a, &k);
      |   ^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...