30292023-02-08 18:00:42horvathabelFasor (40)cpp17Wrong answer 20/40284ms10816 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n,k;
	priority_queue<pair<int, int>> q;
	cin>>n>>k;
	vector<int> fak;
	for (int i=0; i<n;i++){
		int x;
		cin>>x;
		q.push(make_pair(x,i+1));
		fak.push_back(x);
	}
	vector<int> volt;
	vector<bool> vanenagyobb;
	vanenagyobb.resize(n+1, 0);
	int megoi=2000001; 
	int ans=0; 
	for (int i=0; i<n;i++){
		if (q.top().second<megoi){
			bool talale=true; 
			vanenagyobb[q.top().second]=true; 
			for (int j=1; j<=k;j++){
				if (q.top().second+j<n){
					if (vanenagyobb[q.top().second+j] && fak[q.top().second+j-1]!=q.top().first){
						talale=false; 
						break;
					} 
				}
				if (q.top().second-j>=0){
					if (vanenagyobb[q.top().second-j] && fak[q.top().second-j]!=q.top().first){
						talale=false;
						break;
					}
				}
			}
			if (talale){
				megoi=q.top().second; 
				ans=q.top().first;
			}
		}
		q.pop();
	
	}	
	cout<<megoi; 
}
SubtaskSumTestVerdictTimeMemory
base20/40
1Accepted0/03ms1812 KiB
2Accepted0/07ms2488 KiB
3Accepted2/23ms2264 KiB
4Wrong answer0/22ms2352 KiB
5Accepted2/23ms2476 KiB
6Accepted2/23ms2692 KiB
7Accepted2/23ms2788 KiB
8Accepted2/24ms3128 KiB
9Accepted2/26ms3252 KiB
10Accepted2/27ms3248 KiB
11Accepted2/213ms3248 KiB
12Accepted2/27ms3500 KiB
13Time limit exceeded0/2277ms4088 KiB
14Time limit exceeded0/2266ms4268 KiB
15Time limit exceeded0/2270ms6212 KiB
16Time limit exceeded0/2279ms6360 KiB
17Time limit exceeded0/2270ms6412 KiB
18Time limit exceeded0/2239ms6640 KiB
19Time limit exceeded0/2284ms6520 KiB
20Time limit exceeded0/2263ms4888 KiB
21Time limit exceeded0/2273ms6800 KiB
22Accepted2/2115ms10816 KiB