답안 #891629

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
891629 2023-12-23T11:31:03 Z oolimry Martian DNA (BOI18_dna) C++17
100 / 100
280 ms 20564 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;
	map<int,int>req;
	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.find(arr[i])!=req.end()){
			m[arr[i]]++;
			if(m[arr[i]]>=req[arr[i]] and s.find(arr[i])!=s.end()) s.erase(arr[i]);
		}
		while(s.empty()){
			ans=min(ans,i-st+1);
			if(req.find(arr[st])!=req.end()){
				m[arr[st]]--;
				if(m[arr[st]]<req[arr[st]]) s.insert(arr[st]);
			}
			st++;
		}
	}
	if(ans==LLONG_MAX) cout<<"impossible";
	else cout<<ans;
	
	return 0;
}
# 결과 실행 시간 메모리 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 456 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 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 500 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 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1884 KB Output is correct
2 Correct 13 ms 2020 KB Output is correct
3 Correct 21 ms 1880 KB Output is correct
4 Correct 19 ms 1884 KB Output is correct
5 Correct 17 ms 1884 KB Output is correct
6 Correct 16 ms 2396 KB Output is correct
7 Correct 12 ms 2396 KB Output is correct
8 Correct 18 ms 2656 KB Output is correct
9 Correct 16 ms 2764 KB Output is correct
10 Correct 20 ms 2400 KB Output is correct
11 Correct 1 ms 352 KB Output is correct
12 Correct 1 ms 352 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 352 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 348 KB Output is correct
18 Correct 0 ms 348 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 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 272 ms 15772 KB Output is correct
2 Correct 220 ms 13348 KB Output is correct
3 Correct 99 ms 6480 KB Output is correct
4 Correct 15 ms 2412 KB Output is correct
5 Correct 197 ms 16928 KB Output is correct
6 Correct 280 ms 20564 KB Output is correct
7 Correct 98 ms 3932 KB Output is correct
8 Correct 132 ms 5200 KB Output is correct
9 Correct 16 ms 2392 KB Output is correct
10 Correct 14 ms 2396 KB Output is correct
11 Correct 21 ms 2448 KB Output is correct
12 Correct 21 ms 2428 KB Output is correct
13 Correct 19 ms 2784 KB Output is correct
14 Correct 15 ms 2380 KB Output is correct
15 Correct 12 ms 2396 KB Output is correct
16 Correct 18 ms 2652 KB Output is correct
17 Correct 16 ms 2652 KB Output is correct
18 Correct 20 ms 2408 KB Output is correct
19 Correct 1 ms 464 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 468 KB Output is correct
24 Correct 1 ms 344 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 348 KB Output is correct
30 Correct 1 ms 856 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