using
System;
using
System.Collections.Generic;
public
class
GFG{
class
pair : IComparable<pair>
{
public
int
first,second;
public
pair(
int
first,
int
second)
{
this
.first = first;
this
.second = second;
}
public
int
CompareTo(pair p)
{
return
this
.first - p.first;
}
}
static
int
minOperations(
int
[]arr,
int
N,
int
K)
{
List<pair> vp =
new
List<pair>();
for
(
int
i = 0; i < N; i++) {
vp.Add(
new
pair( arr[i], i ));
}
vp.Sort();
int
minCnt = 0;
while
(vp.Count!=0) {
int
val, ind;
val = vp[vp.Count-1].first;
ind = vp[vp.Count-1].second;
minCnt++;
while
(vp.Count!=0
&& vp[vp.Count-1].first == val
&& ind - vp[vp.Count-1].second + 1 <= K)
vp.RemoveAt(vp.Count-1);
}
return
minCnt;
}
public
static
void
Main(String[] args)
{
int
[]arr = { 18, 11, 18, 11, 18 };
int
K = 3;
int
N = arr.Length;
Console.Write(minOperations(arr, N, K));
}
}