# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
936532 | 2024-03-02T05:44:01 Z | dshfjka | Martian DNA (BOI18_dna) | C++14 | 46 ms | 7004 KB |
#include <bits/stdc++.h> #define LL long long using namespace std; int main() { LL n,k,r; scanf("%lld %lld %lld",&n,&k,&r); LL arr[n+5],brr[n+5]; memset(brr,0,sizeof(brr)); for(LL a=1;a<=n;a++) { scanf("%lld",&arr[a]); } for(LL a=1;a<=r;a++) { LL x,y; scanf("%lld %lld",&x,&y); brr[x]=y; } LL left=1,right=n; LL ans=-1; while(left<=right) { LL mid=(left+right)/2; // printf("mid=%lld\n",mid); LL all=0; LL jeje[k+5]; memset(jeje,0,sizeof(jeje)); for(LL a=1;a<=mid;a++) { jeje[arr[a]]++; if(jeje[arr[a]]==brr[arr[a]])all++; // printf("jeje[%lld]=%lld\n",arr[a],jeje[arr[a]]); } if(all==r) { ans=mid; right=mid-1; continue; } bool sudah=0; for(LL a=mid+1;a<=n;a++) { jeje[arr[a-mid]]--; if(jeje[arr[a-mid]]==brr[arr[a-mid]]-1)all--; jeje[arr[a]]++; if(jeje[arr[a]]==brr[arr[a]])all++; // printf("all = %lld\n",all); if(all==r) { ans=mid; right=mid-1; sudah=1; break; } } if(sudah)continue; else { left=mid+1; } } if(ans==-1)printf("impossible\n"); else printf("%lld\n",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 1 ms | 444 KB | Output is correct |
7 | Correct | 0 ms | 344 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 3928 KB | Output is correct |
2 | Correct | 25 ms | 3932 KB | Output is correct |
3 | Correct | 15 ms | 3928 KB | Output is correct |
4 | Correct | 17 ms | 3932 KB | Output is correct |
5 | Correct | 24 ms | 5200 KB | Output is correct |
6 | Correct | 16 ms | 3932 KB | Output is correct |
7 | Correct | 16 ms | 3932 KB | Output is correct |
8 | Correct | 29 ms | 6224 KB | Output is correct |
9 | Correct | 20 ms | 4440 KB | Output is correct |
10 | Correct | 18 ms | 3932 KB | Output is correct |
11 | Correct | 1 ms | 436 KB | Output is correct |
12 | Correct | 1 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 544 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 344 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 5712 KB | Output is correct |
2 | Correct | 33 ms | 5464 KB | Output is correct |
3 | Correct | 36 ms | 5212 KB | Output is correct |
4 | Correct | 14 ms | 3932 KB | Output is correct |
5 | Correct | 35 ms | 6484 KB | Output is correct |
6 | Correct | 46 ms | 7004 KB | Output is correct |
7 | Correct | 25 ms | 4820 KB | Output is correct |
8 | Correct | 30 ms | 4700 KB | Output is correct |
9 | Correct | 17 ms | 3952 KB | Output is correct |
10 | Correct | 23 ms | 3732 KB | Output is correct |
11 | Correct | 15 ms | 3928 KB | Output is correct |
12 | Correct | 16 ms | 3928 KB | Output is correct |
13 | Correct | 23 ms | 5464 KB | Output is correct |
14 | Correct | 17 ms | 3932 KB | Output is correct |
15 | Correct | 17 ms | 3928 KB | Output is correct |
16 | Correct | 28 ms | 6236 KB | Output is correct |
17 | Correct | 19 ms | 4444 KB | Output is correct |
18 | Correct | 19 ms | 3932 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 344 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 600 KB | Output is correct |
26 | Correct | 1 ms | 344 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 0 ms | 348 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Correct | 1 ms | 348 KB | Output is correct |