Submission #1096108

# Submission time Handle Problem Language Result Execution time Memory
1096108 2024-10-03T19:43:21 Z ivaziva Martian DNA (BOI18_dna) C++14
100 / 100
60 ms 4436 KB
#include <bits/stdc++.h>

using namespace std;

#define MAXN 200001

int n,k,rr;
int a[MAXN],b[MAXN],c[MAXN];

int main()
{
    cin>>n>>k>>rr;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int i=1;i<=rr;i++) {int x,y;cin>>x>>y;b[x]=y;}
    int l=1,r=1;c[a[1]]=1;
    int brmanjih=rr;
    if (b[a[1]]==1) brmanjih--;
    int ans=INT_MAX;
    while (l<=r and r<=n)
    {
        if (brmanjih==0)
        {
            ans=min(ans,r-l+1);
            c[a[l]]--;l++;
            if (c[a[l-1]]<b[a[l-1]]) brmanjih++;
            continue;
        }
        if (r==n and brmanjih!=0) break;
        r++;c[a[r]]++;
        if (c[a[r]]<b[a[r]]) continue;
        if (c[a[r]]==b[a[r]]) {brmanjih--;continue;}
    }
    if (ans==INT_MAX) cout<<"impossible"<<endl;
    else cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 1 ms 480 KB Output is correct
6 Correct 1 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 1 ms 344 KB Output is correct
10 Correct 0 ms 440 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 604 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 1404 KB Output is correct
2 Correct 20 ms 1452 KB Output is correct
3 Correct 21 ms 1628 KB Output is correct
4 Correct 21 ms 1560 KB Output is correct
5 Correct 35 ms 2564 KB Output is correct
6 Correct 18 ms 1372 KB Output is correct
7 Correct 21 ms 1576 KB Output is correct
8 Correct 37 ms 3164 KB Output is correct
9 Correct 28 ms 2140 KB Output is correct
10 Correct 17 ms 1372 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 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 448 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 360 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 3412 KB Output is correct
2 Correct 44 ms 3108 KB Output is correct
3 Correct 36 ms 2896 KB Output is correct
4 Correct 17 ms 1372 KB Output is correct
5 Correct 56 ms 3924 KB Output is correct
6 Correct 60 ms 4436 KB Output is correct
7 Correct 28 ms 2160 KB Output is correct
8 Correct 33 ms 2400 KB Output is correct
9 Correct 17 ms 1368 KB Output is correct
10 Correct 18 ms 1628 KB Output is correct
11 Correct 19 ms 1636 KB Output is correct
12 Correct 22 ms 1628 KB Output is correct
13 Correct 32 ms 2540 KB Output is correct
14 Correct 17 ms 1628 KB Output is correct
15 Correct 20 ms 1724 KB Output is correct
16 Correct 34 ms 3164 KB Output is correct
17 Correct 27 ms 2140 KB Output is correct
18 Correct 17 ms 1572 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 476 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 348 KB Output is correct
26 Correct 0 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 0 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 0 ms 348 KB Output is correct