답안 #731667

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
731667 2023-04-27T18:16:39 Z NintsiChkhaidze Martian DNA (BOI18_dna) C++17
0 / 100
35 ms 3924 KB
#include <bits/stdc++.h>
using namespace std;
 
const int N = 2e5 + 5,inf=1e9;
int a[N],mn[N],cnt[N];
 
signed main (){
	
	ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
	int n,k,R;
	cin>>n>>k>>R;
	
	for (int i = 1; i <= n; i++){
		cin>>a[i];
	}
	
	for (int i = 1; i <= k; i++) mn[i] = inf;
	for (int i = 1; i <= R; i++){
		int x,y;
		cin>>x>>y;
		mn[x] = y;
	}
	
	int C = R,r = 1,ans=inf;
	cnt[a[1]]++;
	if (cnt[a[1]] >= mn[a[1]]) --C;
	
	for (int i = 1; i <= n; i++){
		while (C > 0 && r + 1 <= n){
			++r;
			cnt[a[r]]++;
			if (cnt[a[r]] - 1 < mn[a[r]] && cnt[a[r]] >= mn[a[r]]) 
				C--;
		}
		if (C == 0) ans=min(ans,r - i + 1);
		
		cnt[a[i]]--;
		if (cnt[a[i]] + 1 == mn[a[i]] && cnt[a[i]] < mn[a[i]]) ++C;
	}
	if(ans==inf) cout<<"impossible";
	else cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Incorrect 0 ms 340 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1108 KB Output is correct
2 Correct 13 ms 1492 KB Output is correct
3 Correct 13 ms 1508 KB Output is correct
4 Correct 12 ms 1428 KB Output is correct
5 Correct 19 ms 2788 KB Output is correct
6 Correct 11 ms 1412 KB Output is correct
7 Correct 16 ms 1644 KB Output is correct
8 Correct 19 ms 3924 KB Output is correct
9 Correct 15 ms 2120 KB Output is correct
10 Correct 12 ms 1492 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 340 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 320 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Incorrect 1 ms 340 KB Output isn't correct
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1664 KB Output is correct
2 Correct 27 ms 2944 KB Output is correct
3 Correct 20 ms 2812 KB Output is correct
4 Correct 11 ms 1492 KB Output is correct
5 Correct 30 ms 3276 KB Output is correct
6 Correct 35 ms 3924 KB Output is correct
7 Correct 16 ms 2140 KB Output is correct
8 Correct 21 ms 2452 KB Output is correct
9 Correct 12 ms 1492 KB Output is correct
10 Correct 18 ms 1492 KB Output is correct
11 Correct 19 ms 1492 KB Output is correct
12 Correct 12 ms 1492 KB Output is correct
13 Correct 18 ms 2828 KB Output is correct
14 Correct 12 ms 1492 KB Output is correct
15 Correct 14 ms 1676 KB Output is correct
16 Correct 27 ms 3924 KB Output is correct
17 Correct 18 ms 2056 KB Output is correct
18 Correct 12 ms 1492 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 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 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Incorrect 1 ms 324 KB Output isn't correct
34 Halted 0 ms 0 KB -