Submission #960940

# Submission time Handle Problem Language Result Execution time Memory
960940 2024-04-11T09:26:00 Z batsukh2006 Martian DNA (BOI18_dna) C++17
100 / 100
35 ms 6752 KB
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>
#include<utility>
#include<set>
#include<cmath>
#include<queue>
#include<deque>
#include<functional>
#include<stack>
#include<limits.h>
#include<iomanip>
#include<unordered_map> 
#include<numeric>
#include<tuple>
#include<bitset>
using namespace std;
 
#define MOD 1000000007
#define int long long
#define ss second
#define ff first
#define endl '\n'
typedef pair<int,int> pp;
signed main(){
    // freopen("file.in", "r", stdin);
    // freopen("file.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n,k,r; cin>>n>>k>>r;
    vector<int> a(n+1),mp(k+1,-1),fq(k+1);
    for(int i=1; i<=n; i++) cin>>a[i];
    for(int i=1; i<=r; i++){
    	int b,q; cin>>b>>q;
    	mp[b]=q;
    }
    int ans=1e18,sum=0;
    for(int i=1,j=1; i<=n; i++){
    	fq[a[i]]++;
    	if(fq[a[i]]==mp[a[i]]&&mp[a[i]]!=-1) sum++;
    	while(sum==r){
    		ans=min(ans,i-j+1);
    		fq[a[j]]--;
    		if(fq[a[j]]<mp[a[j]]&&mp[a[j]]!=-1) sum--;
    		j++;
    	}
    }
    if(ans==1e18) cout<<"impossible";
    else cout<<ans;
    return 0;
}



























# 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 1 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 568 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 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 500 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 456 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 2396 KB Output is correct
2 Correct 9 ms 2308 KB Output is correct
3 Correct 10 ms 2396 KB Output is correct
4 Correct 9 ms 2396 KB Output is correct
5 Correct 14 ms 4432 KB Output is correct
6 Correct 8 ms 2396 KB Output is correct
7 Correct 9 ms 2392 KB Output is correct
8 Correct 16 ms 6236 KB Output is correct
9 Correct 12 ms 2904 KB Output is correct
10 Correct 9 ms 2396 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 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 532 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 456 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 4948 KB Output is correct
2 Correct 19 ms 4440 KB Output is correct
3 Correct 19 ms 4120 KB Output is correct
4 Correct 9 ms 2392 KB Output is correct
5 Correct 26 ms 5864 KB Output is correct
6 Correct 35 ms 6752 KB Output is correct
7 Correct 14 ms 2912 KB Output is correct
8 Correct 15 ms 3540 KB Output is correct
9 Correct 9 ms 2392 KB Output is correct
10 Correct 12 ms 2400 KB Output is correct
11 Correct 10 ms 2396 KB Output is correct
12 Correct 11 ms 2392 KB Output is correct
13 Correct 15 ms 4188 KB Output is correct
14 Correct 9 ms 2392 KB Output is correct
15 Correct 14 ms 2392 KB Output is correct
16 Correct 20 ms 6236 KB Output is correct
17 Correct 12 ms 3032 KB Output is correct
18 Correct 9 ms 2392 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 348 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 1 ms 344 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 416 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 1 ms 344 KB Output is correct