Submission #927155

# Submission time Handle Problem Language Result Execution time Memory
927155 2024-02-14T10:40:02 Z vjudge1 Martian DNA (BOI18_dna) C++17
0 / 100
72 ms 4948 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lld long double
#define pb push_back
#define pf push_front
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define IShowSpeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=2e5+10;
const int K=200;
const int mod=1e9+7;
const ll inf=1e18+228;
const int dx[]={-1,0,0,1};
const int dy[]={0,-1,1,0};
ll h[N],cnt[N],n,k,r,lol=0,ans=inf;
deque<ll>v;

int main()
{
	//IShowSpeed
	cin>>n>>k>>r;
	for(int i=1;i<=n;i++) cin>>h[i],cnt[i]=-inf;
	for(int i=1;i<=r;i++)
	{
		ll x,y;
		cin>>x>>y;
		cnt[x]=y;
	}
	for(int i=1;i<=n;i++)
	{
		if(cnt[h[i]]==-inf) continue;
		v.pb(i);
		cnt[h[i]]--;
		if(cnt[h[i]]==0) lol++;
		while(cnt[h[v.front()]]<0)
		{
			cnt[h[v.front()]]++;
			v.pop_front();
		}
		if(lol==r) ans=min(v.back()-v.front()+1,ans);
	}
	if(ans==inf) cout<<"Impossible";
	else cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Incorrect 1 ms 2396 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2448 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Incorrect 0 ms 2396 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 4208 KB Output is correct
2 Correct 24 ms 3676 KB Output is correct
3 Correct 24 ms 3440 KB Output is correct
4 Correct 30 ms 4180 KB Output is correct
5 Correct 38 ms 3424 KB Output is correct
6 Correct 24 ms 4948 KB Output is correct
7 Incorrect 25 ms 3676 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 63 ms 4212 KB Output is correct
2 Correct 56 ms 3920 KB Output is correct
3 Correct 46 ms 3572 KB Output is correct
4 Correct 24 ms 3420 KB Output is correct
5 Incorrect 72 ms 4824 KB Output isn't correct
6 Halted 0 ms 0 KB -