답안 #1031147

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1031147 2024-07-22T15:31:09 Z vjudge1 Martian DNA (BOI18_dna) C++17
100 / 100
22 ms 4680 KB
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define pb push_back
#define fi first
#define se second
#define debug(x) cout << #x << " => " << x << endl
#define all(x) x.begin(),x.end()

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n,k,R;cin>>n>>k>>R;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int need[k],cnt[k];
	memset(need,0,sizeof(need));
	memset(cnt,0,sizeof(cnt));
	for(int i=0;i<R;i++)
	{
		int b,q;cin>>b>>q;
		need[b]=q;
	}

	int l=0,r=0,cntOK=0,ans=1e9;
	while(r<n)
	{
		cnt[a[r]]++;
		if(cnt[a[r]]==need[a[r]]) cntOK++;
		r++;
		while(cntOK==R)
		{
			ans=min(ans,r-l);
			cnt[a[l]]--;
			if(cnt[a[l]]==need[a[l]]-1) cntOK--;
			l++;
		}
	}
	if(ans==1e9) cout<<"impossible";
	else 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 Correct 0 ms 464 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 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 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 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 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 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1628 KB Output is correct
2 Correct 8 ms 1372 KB Output is correct
3 Correct 9 ms 1628 KB Output is correct
4 Correct 8 ms 1628 KB Output is correct
5 Correct 12 ms 3260 KB Output is correct
6 Correct 7 ms 1624 KB Output is correct
7 Correct 8 ms 1628 KB Output is correct
8 Correct 13 ms 3904 KB Output is correct
9 Correct 10 ms 2140 KB Output is correct
10 Correct 7 ms 1604 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 492 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 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 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 352 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 352 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 3520 KB Output is correct
2 Correct 16 ms 3164 KB Output is correct
3 Correct 15 ms 2908 KB Output is correct
4 Correct 8 ms 1624 KB Output is correct
5 Correct 19 ms 4180 KB Output is correct
6 Correct 22 ms 4680 KB Output is correct
7 Correct 11 ms 2140 KB Output is correct
8 Correct 16 ms 2576 KB Output is correct
9 Correct 7 ms 1372 KB Output is correct
10 Correct 8 ms 1620 KB Output is correct
11 Correct 9 ms 1628 KB Output is correct
12 Correct 8 ms 1880 KB Output is correct
13 Correct 11 ms 2908 KB Output is correct
14 Correct 7 ms 1628 KB Output is correct
15 Correct 9 ms 1740 KB Output is correct
16 Correct 13 ms 3932 KB Output is correct
17 Correct 10 ms 2140 KB Output is correct
18 Correct 10 ms 1628 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 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 604 KB Output is correct
26 Correct 0 ms 452 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 344 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