Problem:
 Score : 300 points    Problem Statement Every day, N passengers arrive at Takahashi Airport.
The i -th passenger arrives at time T_i .  Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers.
Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport.
Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane.
For that reason, it is necessary to arrange buses so that the i -th passenger can take a bus departing at time between T_i and T_i + K (inclusive).  When setting the departure times for buses under this condition, find the minimum required number of buses.
Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.      Constraints  2 \leq N \leq 100000  1 \leq C \leq 10^9  1 \leq K \leq 10^9  1 \leq T_i \leq 10^9  C , K and T_i are integers.         Input The input is given from Standard Input in the following format:  N  C  K  T_1  T_2  :  T_N       Output Print the minimum required number of buses.        Sample Input 1 5 3 5
1
2
3
6
12      Sample Output 1 3  For example, the following three buses are enough:   A bus departing at time 4.5 , that carries the passengers arriving at time 2 and 3 .  A bus departing at time 6 , that carries the passengers arriving at time 1 and 6 .  A bus departing at time 12 , that carries the passenger arriving at time 12 .        Sample Input 2 6 3 3
7
6
2
8
10
6      Sample Output 2 3

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,C,K=MI()
    T=LIN(N)
    T.sort()
    angry = inf
    now = 0
    ans = 0
    for t in T:
        if(angry < t or now == C):
            ans += 1
            angry = inf
            now = 0
        angry = min(angry,t+K)
        now += 1
        
    ans += angry < inf
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
import sys

N, C, K = map(int, sys.stdin.readline().strip().split())
T = []
for _ in range(N):
    T.append(int(sys.stdin.readline().strip()))

T.sort()
ans = 0
n = 0
left_min = float("inf")
for t_i in T:
    left_min = min(t_i, left_min)
    if left_min + K < t_i:
        ans += 1
        left_min = t_i
        n = 1
        continue

    n += 1
    if n == C:
        ans += 1
        n = 0
        left_min = float("inf")

if n > 0:
    ans += 1

print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, c, k = map(int, readline().split())
t = [int(readline()) for _ in range(n)]
t.sort()
ans = 1
tmp = [t[0], 0]
for tt in t:
    if tmp[0] + k < tt or tmp[1] + 1 > c:
        ans += 1
        tmp = [tt, 0]
    tmp[1] += 1
print(ans)

Solution (Python):


from collections import deque
n,c,k = list(map(int, input().split()))
t = deque(sorted([int(input()) for _ in range(n)]))

cnt=0
bus=[]
while t:
    flg=False
    t1=t.popleft()
    if not bus:
        bus.append(t1)
        flg=True
    elif t1-bus[0]<=k and len(bus)<c:
        bus.append(t1)
        flg=True

    if len(bus)>=c or t1-bus[0]>=k:


        cnt+=1
        bus.clear()

    if not flg:
        bus.append(t1)

if bus:
    cnt+=1
    
print(cnt)

Solution (Python):
n, c, k = map(int, input().split())
t_list = list()
for t in range(n):
    t_list.append(int(input()))

t_list.sort()

ans = 1
c_limit = 1
t_limit = t_list[0] + k

for i in range(1, n):
    t = t_list[i]
    
    if t > t_limit or c_limit >= c:
        ans += 1
        c_limit = 1
        t_limit = t + k
    else:
        c_limit += 1

print(ans)

Solution (Python):
n,c,k = map(int,input().split())
t_input = [int(input()) for i in range(n)]

t_s = sorted(t_input)

ans = 1
c_limit = 1
t_limit = t_s[0]+k
for i in range(1,n):
    t = t_s[i]
    
    if t>t_limit or c_limit>=c:
        ans+=1
        c_limit=1
        t_limit = t+k
    else:
        c_limit+=1
print(ans)

Solution (Python):
n,c,k = map(int,input().split())
list = [int(input()) for _ in range(n)]
sorted_list = sorted(list)
bus = 1
customer = 1
max_hour = sorted_list[0]+k
for i in sorted_list[1:]:
  if i > max_hour or customer >= c:
    bus+=1
    customer=1
    max_hour = i+k
  else:
    customer += 1
print(bus)

Solution (Python):


n, c, k = map(int, input().split())

schedule = []
for _ in range(n):
    t = int(input())
    schedule.append(t)
schedule.sort()

ans = 0
start = schedule[0]
p = 0
for i in range(n):
    s = schedule[i]
    if s <= start + k:
        p += 1
        if p == c:
            ans += 1
            p = 0
            if i + 1 == n:
                break
            start = schedule[i + 1]
    else:
        ans += 1
        start = schedule[i]
        p = 1
if p:
    ans += 1
print(ans)

Solution (Python):


n, c, k = map(int, input().split())

schedule = []
for _ in range(n):
    t = int(input())
    schedule.append(t)
schedule.sort()


def check(num, schedule, c, k):
    bus = 0
    start = schedule[0]
    p = 0
    i = 0
    while i < len(schedule):
        s = schedule[i]
        if s <= start + k:
            p += 1
            i += 1
            if p == c:
                bus += 1
                p = 0
                if i == len(schedule):
                    break
                start = schedule[i]
        else:
            start = schedule[i]
            bus += 1
            p = 1
            i += 1
    if p:
        bus += 1
    if bus <= num:
        return True
    return False

l = 0
r = 10 ** 10
ans = float('inf')
while l <= r:
    mid = (l + r) // 2
    if check(mid, schedule, c, k):
        r = mid - 1
        ans = min(ans, mid)
    else:
        l = mid + 1

print(ans)

Solution (Python):
from collections import Counter

N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

ans = 1
cnt = 0

st = T[0]
for t in T:
    cnt += 1
    
    if t - st > K or cnt > C:
        ans += 1
        st = t
        cnt = 1

print(ans)

Solution (Python):
def main():
    N,C,K = map(int,input().split())
    T = [int(input()) for _ in range(N)]

    T.sort()

    ans,time,rider = 1,T[0],0
    for i in range(N):
        if T[i] <= time + K and rider < C:
            rider += 1
        else:
            ans += 1
            time = T[i]
            rider = 1

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):



n, c, k = map(int, input().split())
T = [int(input()) for _ in range(n)]

T.sort()

ans = 1
cnt = 0
st = T[0]
for t in T:
  cnt += 1
  if t - st > k or cnt > c:
    ans += 1
    st = t
    cnt = 1

print(ans)

Solution (Python):
def answer(n, c, k, ts):
    ts.sort()
    bus = 1
    _c = 1
    standard = ts[0]
    for i in range(1, len(ts)):
        if ts[i] <= standard+k and _c < c:
            _c += 1
        else:
            _c = 1
            standard = ts[i]
            bus += 1
    return bus
    
n, c, k = map(int, input().split())
ts = []
for _ in range(n):
    ts.append(int(input()))
print(answer(n, c, k, ts))

Solution (Python):
a,b,c=map(int,input().split())
l=sorted([int(input()) for i in range(a)])
ans=0
now=l[0]
cur=1
for i in range(1,a):
  x=l[i]
  if cur==b:
    now=x
    cur=1
    ans+=1
  elif x-now>c:
    now=x
    ans+=1
    cur=1
  else:
    cur+=1
print(ans+1)

Solution (Python):
N,C,K=map(int, input().split())
T=[]
for i in range(N):
    t=int(input())
    T.append(t)

T=sorted(T)
ans=0
mint=T[0]
now=1
for i in range(1,N):
    t=T[i]
    if now==C:
        ans+=1
        now=1
        mint=t
    elif t-mint<=K:
        now+=1
    else:
        ans+=1
        now=1
        mint=t
    if i==N-1:
        ans+=1
print(ans)

Solution (Python):
n,c,k = map(int,input().split())
T = sorted([int(input()) for _ in range(n)])

cnt = 0
i = 0
while i < n:
    start = i
    m = 1
    cnt += 1
    while i < n:
        if i - start < c and T[i] - T[start] <= k:
            i += 1
        else:
            break
print(cnt)

Solution (Python):



import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, c, k = LI()
t = [I() for _ in range(n)]
t.sort()
tmp = 0
cnt = 0
ans = 0
if c == 1:
    print(n)
    quit()
for i in range(n):
    if t[i] <= tmp:
        cnt += 1
        if cnt == c:
            cnt = 0
            ans += 1
            if i + 1 < n:
                tmp = t[i+1] + k
            else:
                ans += 1
                break
    else:
        tmp = t[i] + k
        cnt = 1
        ans += 1
print(ans)

Solution (Python):
N,C,K = map(int,input().split())
T = sorted([int(input()) for _ in range(N)])

bus = 1
tmp_bus = 1
bus_time = T[0] + K

for t in T[1:]:

    if tmp_bus < C and t <= bus_time:
        tmp_bus += 1
    else:
        bus += 1
        bus_time = t + K
        tmp_bus = 1

print(bus)

Solution (Python):
N,C,K = map(int,input().split())
T = sorted([int(input()) for _ in range(N)])

bus = 1
tmp_bus = 1
bus_time = T[0] + K

for t in T[1:]:

    if tmp_bus < C and t <= bus_time:
        tmp_bus += 1
    else:
        bus += 1
        bus_time = t + K
        tmp_bus = 1

print(bus)

Solution (Python):
from math import ceil

N,C,K = map(int,input().split())
T = sorted([int(input()) for _ in range(N)])

d_t = T[0]
p = 1
ans = 1

for t in T[1:]:
    if p < C and t-d_t <= K:
        p += 1
    else:
        ans += 1
        d_t = t
        p = 1

print(ans)

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right


from functools import reduce
from pprint import pprint

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,c,k = MI()
T = CI(n)

ls = []
for i in range(n):
    s = T[i]
    t = T[i] + k
    ls.append( [s,t] )

ls = mysort(ls,1,False)



bt = -1*INF
bus = 0
m = 0
for i in range(n):
    s = ls[i][0]
    t = ls[i][1]
    if s>bt:
        bus += 1
        m = 1
        bt = t
    else:
        m += 1
        if m>c:
            bus += 1
            m = 1
            bt = t

print(bus)

Solution (Python):
n,c,k = map(int, input().split())
t = [int(input()) for _ in range(n)]
t.sort()

T = 0
cnt = 0
ans = 0
for i in range(n):
  if cnt == 0: 
    T = t[i] + k
    cnt += 1
  elif t[i] <= T:
    cnt += 1
  elif t[i] > T:
    ans += 1
    cnt = 1
    T = t[i] + k
  if cnt == c:
    ans += 1
    T = 0
    cnt = 0
if cnt != 0: ans += 1
print(ans)

Solution (Python):
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
prev = -1
r = 0
ans = 0
for t in T:
    if prev > 0 and t - prev > K:
        prev = t
        r = 1
        ans += 1
    elif prev < 0:
        prev = t
        ans += 1
        r = 1
    else:
        r += 1

    if r == C:
        prev = -1
        r = 0


print(ans)

Solution (Python):
n,c,k=map(int,input().split())
t=[]
for i in range(n):
    t.append(int(input()))
t.sort()

bus=0
wait_p=0
first_t=-1

for i in range(n):
    ti=t[i]
    if(first_t==-1):
        first_t=ti

    wait_p+=1

    if(ti > first_t+k):
        bus+=1
        first_t=ti
        wait_p=1

    if(wait_p >= c):
        bus+=1
        first_t=-1
        wait_p=0


if(first_t!=-1 or wait_p > 0):
    bus+=1

print(bus)

Solution (Python):
n,c,k = tuple(map(int,input().split()))
t = []

for i in range(n):
  t.append(int(input()))
t = sorted(t)
t_0 = t[0]
p = 1
ans = 0
for t_i in t[1:]:
  if p<c and t_i-t_0<=k:
    p+=1
  else:
    p = 1
    t_0 = t_i
    ans+=1
    
print(ans+1)

Solution (Python):
import sys
input = sys.stdin.readline

N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
now = 0
ans = 0

while now<N:
    ans += 1
    lim = T[now]+K
    
    for _ in range(C):
        if T[now]<=lim:
            now += 1
        else:
            break
        
        if now==N:
            break

print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,c,k=mp()
t=sorted([int(input()) for i in range(n)])
count=1
f=t[0]
ans=1
for i in range(1,n):
    count+=1
    d=t[i]-f
    if d>k or count>c:
        ans+=1
        count=1
        f=t[i]

print(ans)

Solution (Python):
N,C,K = [int(hoge) for hoge in input().split()]
ans = 0
time = -float("inf")
bus = 0
Ts = sorted([int(input()) for i in range(N)])
for T in Ts:
    if (T > time + K) or bus==C:
        ans += 1
        time = T
        bus = 1
    else:
        bus += 1
print(ans)

Solution (Python):
N, C, K = map(int, input().split())
T = sorted([int(input()) for i in range(N)])
b = 0
i = 0
n = 1
t = T[0]
while i < N - 1:
    if n == C:
        b += 1
        n = 1
        i += 1
        t = T[i]
        if i == N - 1:
            b += 1
            break
        else:
            continue
    if t + K < T[i + 1]:
        b += 1
        n = 1
        i += 1
        t = T[i]
        if i == N - 1:
            b += 1
            break
        else:
            continue
    n += 1
    i += 1
    if i == N - 1:
        b += 1
        break

print(b)

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque

n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
t.sort()

l = deque([])
cnt = 0
for i in range(n):
    if len(l) > 0:
        if l[0] + k < t[i]:
            cnt += 1
            l = deque([])
    l.append(t[i])

    if len(l) >= c:
        cnt += 1
        l = deque([])
if len(l) > 0:
    cnt += 1
print(cnt)

Solution (Python):
N,C,K=list(map(int,input().split()))
import sys
l=[r.rstrip() for r in sys.stdin.readlines()]
l=list(map(int,l))
l.sort()
ans=0
now=0
for i in range(N):
   X=l[now]
   for j in range(C):
      if X <= l[now] <= X+K:
         now+=1
         if now==N:
            break
      else:
         break
   ans+=1
   if now==N:
      break
print(ans)

Solution (Python):
n , c , k = map(int,input().split()) 
t = [int(input()) for _ in range(n)]




t = sorted(t)

jyokyaku = 0
bus = 0
for i in t:

  if jyokyaku == 0: 
    bus += 1
    angrytime = i + k
    jyokyaku += 1
    if jyokyaku == c: 
      jyokyaku = 0

  else: 
    if i <= angrytime: 
      jyokyaku += 1
      if jyokyaku == c: 
        jyokyaku = 0

    else: 
      bus += 1
      jyokyaku = 1
      angrytime = i + k

print(bus)

Solution (Python):
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

n,c,k = MI()
t = sorted([I() for _ in range(n)])

cnt = 1
b = 1
bt = t[0]+k
for i in range(1, n):
    if cnt == c or t[i] > bt:
        b += 1
        bt = t[i]+k
        cnt = 1
    else:
        cnt += 1
print(b)

Solution (Python):
N, C, K = map(int, input().split())
T = []
for _ in range(N):
    T.append(int(input()))
T = sorted(T)

ans = 0
c = 0
s = 0

for t in T:
    if (s != 0) and (s + K < t):
        s = 0
        c = 0
        ans += 1

    if s == 0:
        s = t
    c += 1

    if c == C:
        s = 0
        c = 0
        ans += 1
    

if s != 0:
    ans += 1

print(ans)

Solution (Python):
N, C, K = map(int, input().split())
p = 0
bus = 0
time = 0
b = sorted([int(input()) for i in range(N)])
for i in range(N):
    a = b[i]
    if a - time > K or p == C:
        p = 0
    if p == 0:
        time = a
        bus += 1
    p += 1
print(bus)

Solution (Python):


import numpy as np
import sys
import math
input = sys.stdin.readline
n,c,k = map(int,input().split())
A = [int(input()) for i in range(n)]
a = sorted(A)
ans = 0
time = 0.1 
num = 0
for i in range(n):
    if ans == 0:
        ans +=1
        time = a[0] 
        num +=1
    elif ans != 0 and a[i] <= time +k and num < c :
        num +=1
    elif  ans != 0 and (c <=num  or  time +k <=a[i]):
      
        time = a[i] 
        num = 1
        ans +=1
print(ans)

Solution (Python):
N, C, K = map(int, input().split())
t = []
for i in range(N):
    t.append(int(input()))
t.sort()

ans = 0
pt = t[0]
cnt = 1

for i, ct in enumerate(t[1:]):
    if ct - pt > K:
        ans += 1
        cnt = 1
        pt = ct
    elif ct - pt <= K and cnt <= C:
        if cnt == C:
            ans += 1
            cnt = 0
            pt = ct
        cnt += 1
        
if cnt > 0:
    ans += 1
    
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    n, c, k = MI()

    T = [-1] * n
    for i in range(n):
        T[i] = II()
    T = sorted(T)

    bus_cnt = 1
    person_cnt = 0
    th = T[0] + k
    for i in T:
        
        if i > th or person_cnt + 1 > c:
            bus_cnt += 1
            person_cnt = 1
            th = i + k
        else:
            person_cnt += 1
    print(bus_cnt)

if __name__ == '__main__':
    solve()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    n, c, k = MI()

    T = [-1] * n
    for i in range(n):
        T[i] = II()
    T = sorted(T)

    bus_cnt = 1
    person_cnt = 0
    th = T[0] + k
    for i in T:
        
        if i <= th:
            if person_cnt + 1 > c:
                bus_cnt += 1
                th = i + k
                person_cnt = 1
            else:
                person_cnt += 1
        else:
            bus_cnt += 1
            person_cnt = 1
            th = i + k
    print(bus_cnt)

if __name__ == '__main__':
    solve()

Solution (Python):
n, c, k = map(int, input().split())
arrivals = {}
for _ in range(n):
    t = int(input())
    if t in arrivals:
        arrivals[t] += 1
    else:
        arrivals[t] = 1
data = sorted(arrivals.keys())
ans = 0
current_bus_seats = c
bus_wait_from = data[0]
for time in data:
    ppl = arrivals[time]
    if current_bus_seats != c:
        if time - bus_wait_from > k:
            ans += 1
        else:
            if ppl <= current_bus_seats:
                current_bus_seats -= ppl
                continue
            else:
                ppl -= current_bus_seats
                ans += 1
    current_bus_seats = c
    bus_wait_from = time
    d, m = divmod(ppl, c)
    ans += d
    current_bus_seats -= m
if current_bus_seats < c:
    ans += 1
print(ans)

Solution (Python):


N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
ans = 0
c = 0
dead_time = 0

for i in range(N):
    if c==0 or T[i]>dead_time:
        dead_time = T[i]+K
        ans += 1
        c = 0
    c = (c+1)%C

print(ans)

Solution (Python):
n,c,k=map(int,input().split())
ans=0
cnt=1
t=sorted([int(input())for s in range(n)])
while t:
    now=t.pop()
    ans+=1
    while t and cnt<c and t[-1]+k>=now:
        cnt+=1
        t.pop()
    cnt=1

print(ans)

Solution (Python):
import bisect

n,c,k = list(map(int, input().split()))
t = []
for i in range(n):
	t.append(int(input()))
t.sort()

ans = 0
remain = c-1
if c==1:
	print(n)
	exit()
time = t[0]
for i in range(1,len(t)):
	if time+k<t[i]:
		time = t[i]
		remain = c
		ans+=1
	if remain==0:
		remain=c
		time = t[i]
		ans+=1
	remain-=1

print(ans+1)

Solution (Python):
N,C,K=map(int,input().split())
T=[int(input())for i in range(N)]
T.sort()
ans=0
bus_seat=0
tmp_time=0
for i in range(len(T)):
    if T[i]>tmp_time+K:
        bus_seat=0
    if bus_seat==0:
        ans+=1
        tmp_time=T[i]
    
    bus_seat+=1
    if bus_seat==C:
        bus_seat=0
print(ans)

Solution (Python):
N,C,K=map(int,input().split())
import heapq
T=[]
heapq.heapify(T)
for i in range(N):
    heapq.heappush(T,int(input()))

ans=1
p=1
start=heapq.heappop(T)

for i in range(N-1):
    t=heapq.heappop(T)
    p+=1
    if p<=C and t<=start+K:
        continue
    else:
        start=t
        ans+=1
        p=1

print(ans)

Solution (Python):
N,C,K=map(int,input().split())
import heapq
T=[]
heapq.heapify(T)
for i in range(N):
    heapq.heappush(T,int(input()))

ans=1
p=1
start=heapq.heappop(T)

for i in range(N-1):
    t=heapq.heappop(T)
    p+=1
    if p<=C and t<=start+K:
        continue
    else:
        start=t
        ans+=1
        p=1

print(ans)

Solution (Python):
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))



def main():
    n, c, k = ns()
    t = [ni() for _ in range(n)]
    t.sort()

    ans = 0
    idx = 0
    while idx < n:
        ans += 1

        k_idx = bisect.bisect_right(t, t[idx] + k)
        c_idx = idx + c

        idx = min(k_idx, c_idx)

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy





sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))



def main():
    n, c, k = ns()
    t = [ni() for _ in range(n)]
    t.sort()

    ans = 0
    idx = 0
    while True:
        ans += 1

        k_idx = bisect.bisect_right(t, t[idx] + k)
        c_idx = idx + c

        idx = min(k_idx, c_idx)
        if idx > n-1:
            break

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n, c, k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()
cnt = 1
buss = 0
fir = t[0]
for i in range(1, n):
    if fir <= t[i] and t[i] <= fir + k and cnt < c:
        cnt += 1
    else:
        buss += 1
        cnt = 1
        fir = t[i]
if cnt >= 1:
    buss += 1
print(buss)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    T.sort()

    first = T[0]
    cnt = 1
    ans = 0
    for i in range(1, N):
        if cnt == C:
            ans += 1
            first = T[i]
            cnt = 1
        elif first + K < T[i]:
            ans += 1
            first = T[i]
            cnt = 1
        else:
            cnt += 1
    ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n,c,k=map(int,input().split())
t=[]
for _ in range(n):
    t.append(int(input()))
t.sort()

def bus(M):
    j=1
    count=0
    I=t[0]
    for i in range(n):
        if I+k>=t[i] and count<c: 
            count+=1
        else:
            I=t[i]
            count=1
            j+=1
    if j<=M:
        return True
    else:
        return False

start=0
end=n
while end-start>1:
    ty=(start+end)//2
    if bus(ty):
        end=ty
    else:
        start=ty
print(end)

Solution (Python):
n,c,k = map(int,input().split())
l = sorted(list(int(input()) for _ in range(n)))
bus = 1
now = 1
time = l[0]+k
for i in range(1,n):
  b = l[i]
  if b<=time and time<=b+k and now<c:
    now += 1
  else:
    bus += 1
    now = 1
    time = l[i]+k
print(bus)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,c,k=mp()
t=sorted([int(input()) for i in range(n)])
count=1
f=t[0]
ans=1
for i in range(1,n):
    count+=1
    d=t[i]-f
    if d>k or count>c:
        ans+=1
        count=1
        f=t[i]

print(ans)

Solution (Python):
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
t.sort()

t_crr = t[0]
cnt = 0
ans = 1

for i in t:
    
    if i - t_crr <= k and cnt < c:
        cnt += 1
        continue
    else:
        t_crr = i
        ans += 1
        cnt = 1

print(ans)

Solution (Python):


n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
t.sort(reverse=True)

t_b = t[0]
cnt = 0
ans = 0

for i in t:
    
    if t_b - i <= k and cnt + 1 <= c: 
        cnt += 1
        continue
    else:
        t_b = i
        cnt = 1
        ans += 1

print(ans + 1)

Solution (Python):
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
bus = 0
count = 0
j = 0
for i in range(N-1):
  count += 1
  if count >= C or T[i+1] > T[j]+K:
    bus += 1
    j += count
    count = 0
  if i == N-2:
    count += 1
    if count%C == 0:
      bus += count//C
    else:
      bus += count//C+1
print(bus)

Solution (Python):
N, C, K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort(reverse = True)
counter = 1
i = 0           
A = T.pop()     
while T:
  a = T.pop()
  i+=1
  if i>=C or a>A+K:
    i=0
    A=a
    counter += 1
  
print(counter)

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N,C,K = list(map(int,_in[0].split(' ')))  
    T_arr = []
    for i in range(N):
        _ = int(_in[i+1])  
        T_arr.append(_)
    
    T_arr.sort()
    cnt = 0
    i = 0
    while True:
        c = 1
        tlim = T_arr[i]+K
        i += 1
        while i<N and T_arr[i]<=tlim and c+1<=C:
            i += 1
            c += 1
        cnt += 1
        if i>=N:
            break
    
    print(cnt)

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N, C, K = map( int, input().split())
    T = [ int( input()) for _ in range(N)]
    T.sort()
    deadline = -1
    ans = 0
    count = 0
    for t in T:
        if deadline < t or count >= C:
            ans += 1
            deadline = t+K
            count = 1
            continue
        count += 1

    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    n, c, k = map(int, input().split())
    t = [int(input()) for _ in range(n)]

    t.sort()

    waitP = 1
    l = t[0]
    ans = 0

    for i in range(1, n):
        if waitP == c:
            ans += 1
            l = t[i]
            waitP = 1
            if i == n - 1:
                ans += 1
        elif waitP != c:
            if t[i] - l <= k:
                waitP += 1
                if i == n - 1:
                    ans += 1
            elif t[i] - l > k:
                ans += 1
                l = t[i]
                waitP = 1
                if i == n - 1:
                    ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import deque
n,c,k = map(int,input().split())
t = []
for _ in range(n):
    tt = int(input())
    t.append(tt)
t.sort()
ans = deque([])
cnt = 0
for i, tt in enumerate(t):
    if i == 0:
        ans.append([tt+k,1])
        cnt += 1
    else:
        flg = False
        for i in range(len(ans)):
            tmp = ans.popleft()
            if tmp[0] < tt or tmp[1] == c:

                continue
            else:
                flg = True
                break
        if flg :
            tmp[1] += 1
            if tmp[1] != c:
                ans.appendleft(tmp)
        else:
            tmp = [tt+k,1]
            ans.append(tmp)
            cnt += 1
print(cnt)

Solution (Python):
import numpy as np
n,c,k=map(int,input().split())
t=list(int(input()) for _ in range(n))
t.sort()
t=np.array(t)
s=0
num=0
while True:
    e=np.searchsorted(t,t[s]+k,side="right")
    if e-s>c:
        s=s+c
    else:
        s=e
    num+=1
    if s>n-1:
        break
print(num)