Submission #1098726

# Submission time Handle Problem Language Result Execution time Memory
1098726 2024-10-09T19:26:52 Z vjudge1 Martian DNA (BOI18_dna) C++17
100 / 100
177 ms 10384 KB
#include <bits/stdc++.h>

using namespace std;

#define ar array
#define int long long
#define ld long double
#define crash assert(69 == 420)

const int N = 2005;
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int X = 100;


map<int,int> mp;
int cnt;

void add(int x){
	if(!mp.count(x))return;
	mp[x]--;
	if(mp[x] == 0)cnt--;
}

void rem(int x){
	if(!mp.count(x))return;
	if(mp[x] == 0)cnt++;
	mp[x]++;
}

signed main(){ios_base::sync_with_stdio(false);cin.tie(0);
	int n, k, r;
	cin>>n>>k>>r;
	int A[n];
	for(int i = 0;i < n;i++)cin>>A[i];
	//map<int, int> mp;
	cnt = r;
	while(r--){
		int x, y;
		cin>>x>>y;
		mp[x] = y;
	}
	int mr = -1;
	int ans = INF;
	for(int i =0;i < n;i++){
		while(mr + 1 < n && cnt)add(A[++mr]);
		if(!cnt)ans = min(ans, mr - i + 1);
		rem(A[i]);
	}
	if(ans >= INF)cout<<"impossible";
	else cout<<ans;
}	
# 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 1 ms 460 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 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 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 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 344 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 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2396 KB Output is correct
2 Correct 12 ms 2256 KB Output is correct
3 Correct 14 ms 2392 KB Output is correct
4 Correct 14 ms 2392 KB Output is correct
5 Correct 18 ms 3160 KB Output is correct
6 Correct 18 ms 2396 KB Output is correct
7 Correct 14 ms 2396 KB Output is correct
8 Correct 20 ms 3164 KB Output is correct
9 Correct 16 ms 2904 KB Output is correct
10 Correct 18 ms 2392 KB Output is correct
11 Correct 1 ms 456 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 600 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 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 452 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 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 177 ms 8788 KB Output is correct
2 Correct 149 ms 7252 KB Output is correct
3 Correct 82 ms 4444 KB Output is correct
4 Correct 10 ms 2404 KB Output is correct
5 Correct 166 ms 9040 KB Output is correct
6 Correct 162 ms 10384 KB Output is correct
7 Correct 93 ms 3416 KB Output is correct
8 Correct 106 ms 4140 KB Output is correct
9 Correct 12 ms 2392 KB Output is correct
10 Correct 10 ms 2396 KB Output is correct
11 Correct 12 ms 2380 KB Output is correct
12 Correct 12 ms 2392 KB Output is correct
13 Correct 17 ms 3164 KB Output is correct
14 Correct 16 ms 2408 KB Output is correct
15 Correct 14 ms 2588 KB Output is correct
16 Correct 18 ms 3164 KB Output is correct
17 Correct 16 ms 2904 KB Output is correct
18 Correct 17 ms 2392 KB Output is correct
19 Correct 0 ms 344 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 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 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 456 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct