Submission #891587

# Submission time Handle Problem Language Result Execution time Memory
891587 2023-12-23T09:16:01 Z jellybean Martian DNA (BOI18_dna) C++17
100 / 100
194 ms 17608 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n,k,r; cin>>n>>k>>r;
	int arr[n];
	map<int,int>m;
	int req[n]={};
	set<int>s;
	for(int i=0; i<n; i++) cin>>arr[i];
	for(int i=0; i<r; i++){
		int a,b; cin>>a>>b;
		req[a]=b;
		s.insert(a);
	}
	int st=0,ans=LLONG_MAX;
	for(int i=0; i<n; i++){
		if(req[arr[i]]) m[arr[i]]++;
		if(m[arr[i]]>=req[arr[i]] and s.find(arr[i])!=s.end()) s.erase(arr[i]);
		while(s.empty()){
			//cout<<st<<" "<<i<<endl;
			ans=min(ans,i-st+1);
			if(req[arr[st]]){
				m[arr[st]]--;
				if(m[arr[st]]<req[arr[st]]) s.insert(arr[st]);
				//if(st==2) cout<<"hi "<<s.size()<<endl;
			}
			st++;
		}
	}
	if(ans==LLONG_MAX) cout<<"impossible";
	else cout<<ans;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 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 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 856 KB Output is correct
5 Correct 1 ms 604 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 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 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 3420 KB Output is correct
2 Correct 15 ms 3932 KB Output is correct
3 Correct 20 ms 3932 KB Output is correct
4 Correct 18 ms 3792 KB Output is correct
5 Correct 52 ms 9300 KB Output is correct
6 Correct 14 ms 3928 KB Output is correct
7 Correct 17 ms 3932 KB Output is correct
8 Correct 80 ms 17184 KB Output is correct
9 Correct 32 ms 4952 KB Output is correct
10 Correct 17 ms 3932 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 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 600 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 460 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 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 141 ms 9144 KB Output is correct
2 Correct 123 ms 9300 KB Output is correct
3 Correct 79 ms 8788 KB Output is correct
4 Correct 16 ms 3948 KB Output is correct
5 Correct 115 ms 15700 KB Output is correct
6 Correct 194 ms 17608 KB Output is correct
7 Correct 56 ms 5212 KB Output is correct
8 Correct 82 ms 6352 KB Output is correct
9 Correct 15 ms 3928 KB Output is correct
10 Correct 15 ms 3932 KB Output is correct
11 Correct 20 ms 3932 KB Output is correct
12 Correct 17 ms 3932 KB Output is correct
13 Correct 51 ms 9700 KB Output is correct
14 Correct 14 ms 3928 KB Output is correct
15 Correct 17 ms 3932 KB Output is correct
16 Correct 82 ms 17236 KB Output is correct
17 Correct 32 ms 4956 KB Output is correct
18 Correct 17 ms 3888 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 604 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 464 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 348 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 344 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