Submission #975224

# Submission time Handle Problem Language Result Execution time Memory
975224 2024-05-04T15:03:40 Z Nipphitch Martian DNA (BOI18_dna) C++14
0 / 100
20 ms 2652 KB
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;

int n,k,r,a[N],cnt[N],mn[N],now=1,ans;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k >> r;
	for(int i=1;i<=n;i++) cin >> a[i];
	for(int i=0;i<r;i++){
		int x,y;
		cin >> x >> y;
		mn[x]=y;
	}
	for(int i=0;i<k;i++) while(cnt[i]<mn[i] && now<=n) cnt[a[now++]]++;
	for(int i=0;i<k;i++) if(cnt[i]<mn[i]) cout << "imposible",exit(0);
	ans=now-1;
	for(int i=1;i<n;i++){
		cnt[a[i]]--;
		while(cnt[a[i]]<mn[a[i]] && now<=n) cnt[a[now++]]++;
		if(cnt[a[i]]<mn[a[i]]) break;
		ans=min(ans,now-i);
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -