답안 #891131

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
891131 2023-12-22T08:18:00 Z Kiameimon_Welt_Rene Martian DNA (BOI18_dna) C++14
0 / 100
42 ms 11116 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define elif else if
#define dbg(v)\
	cout << "line(" << __LINE__ << ") -> " << #v << " = " << (v) << endl;
	
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	int n, k, R; cin >> n >> k >> R;
	int req[n], cnt[n], arr[n], sz = 0;
	unordered_set<int> nums;
	fill(req, req+n, 0); fill(cnt, cnt+n, 0);
	for(int i = 0; i < n; i++) cin >> arr[i];
	for(int i = 0; i < R; i++){
		int b, q; cin >> b >> q; sz += q;
		req[b] = q; nums.insert(b);
	}
	int l = 0, r = 0, ans = LLONG_MAX;
	while(r < n){
		while(!nums.empty() && r < n){
			int val = arr[r]; cnt[val]++;
			if(req[val] != 0 && cnt[val] >= req[val]) nums.erase(val);
			r++;
		}
		if(r == n) break;
		ans = min(ans, r-l);
		int val = arr[l]; cnt[val]--;
		if(cnt[val] < req[val]) nums.insert(val);
		l++;
	}
	while(l < n-sz && nums.empty()){
		ans = min(ans, r-l+1);
		int val = arr[l]; cnt[val]--;
		if(cnt[val] < req[val]) break;
		l++;		
	}
	
	if(ans == LLONG_MAX){cout << "impossible"; return 0;}
	cout << ans;
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 456 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 4956 KB Output is correct
2 Correct 14 ms 5544 KB Output is correct
3 Correct 16 ms 5464 KB Output is correct
4 Correct 15 ms 5464 KB Output is correct
5 Correct 15 ms 5724 KB Output is correct
6 Incorrect 10 ms 5516 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 8112 KB Output is correct
2 Correct 32 ms 8548 KB Output is correct
3 Correct 21 ms 6824 KB Output is correct
4 Correct 22 ms 5468 KB Output is correct
5 Correct 32 ms 9488 KB Output is correct
6 Correct 42 ms 11116 KB Output is correct
7 Correct 16 ms 6236 KB Output is correct
8 Correct 18 ms 6492 KB Output is correct
9 Correct 12 ms 5464 KB Output is correct
10 Correct 14 ms 5468 KB Output is correct
11 Correct 16 ms 5576 KB Output is correct
12 Correct 17 ms 5464 KB Output is correct
13 Correct 17 ms 5724 KB Output is correct
14 Incorrect 10 ms 5464 KB Output isn't correct
15 Halted 0 ms 0 KB -