Submission #951602

# Submission time Handle Problem Language Result Execution time Memory
951602 2024-03-22T07:20:43 Z SaMuEl0516 Martian DNA (BOI18_dna) C++17
100 / 100
25 ms 4856 KB
#include<bits/stdc++.h>
using namespace std;
int q[(int)2e5+5],cnt[(int)2e5+5],a[(int)2e5+5];
int main(){
    cin.tie(0)->sync_with_stdio(0);
    int n,k,r,x,y,ans=1e9;
    cin>>n>>k>>r;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<r;i++){
        cin>>x>>y;
        q[x]=y;
    }
    for(int i=0,j=0;;j++){
        if(j==n)break;
        if(++cnt[a[j]]==q[a[j]])r--;
        if(r==0){
            while(cnt[a[i]]-1>=q[a[i]]){
                cnt[a[i]]--;
                i++;
            }
            ans=min(ans,j-i+1);
        }
    }
    if(ans==1e9)cout<<"impossible";
    else cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2504 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2420 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2904 KB Output is correct
2 Correct 9 ms 2920 KB Output is correct
3 Correct 10 ms 2912 KB Output is correct
4 Correct 9 ms 2912 KB Output is correct
5 Correct 13 ms 3788 KB Output is correct
6 Correct 11 ms 3164 KB Output is correct
7 Correct 11 ms 3176 KB Output is correct
8 Correct 14 ms 4176 KB Output is correct
9 Correct 11 ms 3428 KB Output is correct
10 Correct 9 ms 2908 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2520 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2648 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 4340 KB Output is correct
2 Correct 19 ms 4188 KB Output is correct
3 Correct 18 ms 4112 KB Output is correct
4 Correct 9 ms 2908 KB Output is correct
5 Correct 22 ms 4856 KB Output is correct
6 Correct 25 ms 4752 KB Output is correct
7 Correct 12 ms 3672 KB Output is correct
8 Correct 15 ms 3676 KB Output is correct
9 Correct 11 ms 2904 KB Output is correct
10 Correct 9 ms 2908 KB Output is correct
11 Correct 10 ms 2908 KB Output is correct
12 Correct 9 ms 2908 KB Output is correct
13 Correct 14 ms 3960 KB Output is correct
14 Correct 8 ms 2908 KB Output is correct
15 Correct 9 ms 3160 KB Output is correct
16 Correct 14 ms 3932 KB Output is correct
17 Correct 11 ms 3420 KB Output is correct
18 Correct 9 ms 2908 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2408 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2404 KB Output is correct
25 Correct 1 ms 2404 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2404 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2408 KB Output is correct
30 Correct 1 ms 2400 KB Output is correct
31 Correct 1 ms 2652 KB Output is correct
32 Correct 1 ms 2408 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct