106292024-04-07 00:20:52111Karácsonyi égőkcpp17Wrong answer 0/10030ms18628 KiB
#include<bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N,M;
	cin>>N>>M;
	int ans=N;
	vector<int>v(M,-1);
	deque<pair<int,int>>q;
	for(int i=0;i<N;i++){
		int x;
		cin>>x;
		v[x]=i;
		q.emplace_back(x,i);
		while(v[q.front().first]!=q.front().second){
			q.pop_front();
		}
		if(q.size()>=M){
			ans=min(ans,q.back().second-q.front().second+2);
		}
	}
	cout<<ans<<'\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2084 KiB
subtask20/15
3Wrong answer20ms6100 KiB
4Wrong answer20ms6700 KiB
5Wrong answer20ms7012 KiB
6Wrong answer3ms4236 KiB
7Wrong answer3ms4240 KiB
subtask30/10
8Accepted2ms4104 KiB
9Wrong answer3ms4176 KiB
10Wrong answer2ms4240 KiB
11Wrong answer3ms4248 KiB
12Wrong answer2ms4252 KiB
subtask40/20
13Wrong answer3ms4388 KiB
14Wrong answer3ms4620 KiB
15Wrong answer3ms4716 KiB
16Wrong answer3ms4936 KiB
17Wrong answer3ms5148 KiB
subtask50/25
18Accepted3ms5380 KiB
19Wrong answer3ms5548 KiB
20Wrong answer3ms5608 KiB
21Wrong answer3ms5472 KiB
22Wrong answer3ms5504 KiB
subtask60/30
23Accepted30ms16408 KiB
24Wrong answer24ms13520 KiB
25Wrong answer26ms14404 KiB
26Wrong answer28ms16048 KiB
27Wrong answer28ms18628 KiB
28Wrong answer26ms17716 KiB
29Wrong answer23ms14264 KiB
30Wrong answer19ms17824 KiB