Submission #657338

# Submission time Handle Problem Language Result Execution time Memory
657338 2022-11-09T15:42:39 Z teesla Martian DNA (BOI18_dna) C++14
100 / 100
102 ms 4488 KB
#include <bits/stdc++.h>
using namespace std; 
const int maxn=2*1e5+10;
const int inf=1e8;

int v[maxn], nucleo[maxn], qnt[maxn];

int main(){
	int n,k,r;
	cin >> n>> k>> r;

	int rest=r;
	int res=inf;

	for(int i=0; i<n; i++)cin >> v[i];

	for(int i=1; i<=r; i++){
		int a,b;
		cin >> a >> b;
		nucleo[a]=b;
	}

	int i=0,f=0;

	int y=v[i];
	qnt[y]++;
	if(nucleo[0]!=0 and qnt[y]==nucleo[0]) rest--;

	while(i<n and f<n and i<=f){

		if(rest==0){
			res=min(res,f-i+1);
			int x=v[i];
			qnt[x]--;
			if(nucleo[x]!=0 and qnt[x]==nucleo[x]-1) rest++;
			i++;
		}

		else{
			f++;
			int x=v[f];
			qnt[x]++;
			if(nucleo[x]!=0 and nucleo[x]==qnt[x]) rest--;
		}
	}

	if(res==inf)cout << "impossible"<<endl;
	else cout << res<< endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 308 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1460 KB Output is correct
2 Correct 29 ms 1356 KB Output is correct
3 Correct 32 ms 1468 KB Output is correct
4 Correct 28 ms 1388 KB Output is correct
5 Correct 56 ms 2544 KB Output is correct
6 Correct 31 ms 1356 KB Output is correct
7 Correct 35 ms 1592 KB Output is correct
8 Correct 64 ms 3148 KB Output is correct
9 Correct 50 ms 1960 KB Output is correct
10 Correct 30 ms 1356 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 312 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 304 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 304 KB Output is correct
25 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 102 ms 3352 KB Output is correct
2 Correct 81 ms 3124 KB Output is correct
3 Correct 62 ms 2728 KB Output is correct
4 Correct 29 ms 1448 KB Output is correct
5 Correct 97 ms 4044 KB Output is correct
6 Correct 101 ms 4488 KB Output is correct
7 Correct 50 ms 2124 KB Output is correct
8 Correct 56 ms 2396 KB Output is correct
9 Correct 30 ms 1440 KB Output is correct
10 Correct 33 ms 1416 KB Output is correct
11 Correct 31 ms 1384 KB Output is correct
12 Correct 30 ms 1396 KB Output is correct
13 Correct 59 ms 2524 KB Output is correct
14 Correct 28 ms 1360 KB Output is correct
15 Correct 34 ms 1640 KB Output is correct
16 Correct 60 ms 3124 KB Output is correct
17 Correct 50 ms 1992 KB Output is correct
18 Correct 30 ms 1460 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 2 ms 320 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 308 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct