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



Sample input:
5 3 5
1
2
3
6
12


Sample output:
3

Submission status: Accepted

Solution code:
_, c, k, *lst = map(int, open(0).read().split())
lst.sort()
res = 1
tmpt = lst[0]
tmpc = 0
for i in lst:
  tmpc += 1
  if not (tmpc <= c and i - tmpt <= k):
    res += 1
    tmpc = 1
    tmpt = i

print(res)

Submission status: Accepted

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

bus=0
arr=0
que=0
for i in range(n):
  tt=t[i]
  if que==0:
    #print('que=0,i,bus,arr,que,t[i]',i,bus,arr,que,t[i])
    arr=tt
    que+=1
    bus+=1
  else:
    if que==c:
      #print('q==c,i,bus,arr,que,t[i]',i,bus,arr,que,t[i])
      bus+=1
      arr=tt
      que=1
    else:
      if arr+k<tt:
        #print('dep,i,bus,arr,que,t[i]',i,bus,arr,que,t[i])
        bus+=1
        arr=tt
        que=1
      else:
        #print('waiting,i,bus,arr,que,t[i]',i,bus,arr,que,t[i])
        que+=1

print(bus)

Submission status: Accepted

Solution code:
N,C,K=map(int,input().split())
T=sorted([int(input()) for i in range(N)])
lt=T[0]+K
m=0
b=0
for t in T:
    if lt>=t and m<C:
        m+=1
    else:
        m=1
        b+=1
        lt=t+K
if m>=1:
    b+=1
print(b)

Submission status: Accepted

Solution code:
n,c,k = map(int,input().split())
t = [0]*n
for i in range(n):
    t[i] = int(input())
t.sort()
ind = 0
ans = 0
bus = 0
while ind <= n-1:
    bus += 1
    ind_o = ind
    for i in range(c):
        if ind_o+i > n-1:
            ind_o += i-1
            break
        if t[ind_o+i] > t[ind_o]+k:
            break
        else:
            ind += 1
print(bus)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, C, K = MAP()
T = [INT() for _ in range(N)]

T.sort()

ans = 1
cnt = 1
t_limit = T[0] + K

for i in range(1, N):
	if cnt == C:   #人数上限
		t_limit = T[i] + K
		cnt = 1
		ans += 1
	elif T[i] <= t_limit: #乗れる
		cnt += 1 
	else:          #待ち時間上限
		t_limit = T[i] + K
		cnt = 1
		ans += 1
print(ans)

Submission status: Accepted

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

buf.sort()

ans = 0
lasttime = 1e9
tcnt = 0
for i in range(n):
    if i == 0:
        tcnt += 1
        lasttime = buf[i]
        ans += 1
    else:
        t = buf[i]
        if t <= lasttime+k and tcnt < c:
            tcnt += 1
        else:
            ans += 1
            lasttime = buf[i]
            tcnt = 1
    # print(ans)
print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, C, K = MAP()
T = [INT() for _ in range(N)]

T.sort()
idx = 0
ans = 0

while idx < N :
	tmp = T[idx]
	if idx+C <= bisect(T, tmp+K):
		idx += C
	else:
		idx = bisect(T, tmp+K)
	ans += 1

print(ans)

Submission status: Accepted

Solution code:
n,c,k = map(int, input().split())
T = []
for i in range(n):
    T.append(int(input()))
T.sort()
ans = 1
last_t = T[0]
passengers = 0
for t in T:
    if last_t +k >= t and passengers < c:
        passengers += 1
    else:
        last_t = t
        passengers = 1
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
np, cp, tl = map(int, input().split())
bn = [1] + [0 for i in range(np-1)]
ar = []
for i in range(np):
  ar.append(int(input())) 
ar.sort()

lim = ar[0] + tl
num = 1
gto = 1
for i in range(1, np):
  if gto == cp or lim < ar[i]:
    lim = ar[i] + tl
    gto = 1
    num += 1
    bn[i] = num
  else:
    gto += 1
    bn[i] = num

print(bn[-1])

Submission status: Accepted

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

ans = 1
bus = 0
before = T[0]

for i in T:
    if bus+1 > C or i - before > K:
        bus = 1
        ans += 1
        before = i
    else:
        bus += 1
    
    # print(f"i{i} bus{bus} ans{ans}")
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AtoZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N,C,K = IL()
T = ILs(N)
T.sort()

now = 0
count = 0
while now < N:
  t = T[now]
  p = bisect.bisect_right(T,t+K)
  count += 1
  now = min(now+C,p)
print(count)

Submission status: Accepted

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

t=[]

for _ in range(n):
    t_i = int(input())

    t.append(t_i)

t = sorted(t)

bus=0
index=0
cnt=0

start =t[index]
while index<n:

    end = t[index]

    if end<=start+k:
        if cnt==c:
            bus+=1
            start=t[index]
            cnt=1
            index+=1
        else:
            cnt+=1
            index+=1
            if index==n:
                break
    else:
        bus+=1
        start=t[index]
        cnt=1
        index+=1

if cnt<=c:
    bus+=1

print(bus)

Submission status: Accepted

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

    T.sort()

    ans = 0
    temp = T[0]
    cnt = 1

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

    ans += 1
    return (ans)

print(main())

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,c,k=map(int, input().split())
    l=[int(input()) for i in range(n)]
    l.sort()
    saisyo=l[0]
    ninzu=1
    ans=0
    for j in range(1,n):
        x=l[j]-saisyo
        if x<=k and ninzu<c:
            ninzu+=1
        else:
            ans+=1
            saisyo=l[j]
            ninzu=1
    print(ans+1)
resolve()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
ans = 0
cnt = 1
mn = T[0]
for i in range(1,N):
    if cnt == C or mn+K < T[i]:
        ans += 1
        cnt = 1
        mn = T[i]
    else:
        cnt += 1
if cnt > 0:
    ans += 1
print(ans)

Submission status: Accepted

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

buses = 0
passengers = 1
first = ts[0]
for t in ts[1:]:
    if t > first + k or passengers == c:
        buses += 1
        passengers = 1
        first = t
    else:
        passengers += 1

if passengers > 0:
    buses += 1

print(buses)

Submission status: Accepted

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
# @lru_cache(None)





n,c,k=l()
A=[l()[0] for i in range(n)]
A.sort()
i=0
count=0
while(i<n):
    j=i
    while(i<n and A[j]+k>=A[i]and i-j+1<=c):
        i+=1
    count+=1
print(count)

Submission status: Accepted

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

T.sort()

ans = 0

oko = 0
bus = False
cnt = 0
for i in range(N):
  t = T[i]
  
  if not bus:
    ans += 1
    bus = True
    oko = t + K
    cnt += 1
    continue
    
  if t <= oko:
    if cnt < C:
      cnt += 1
    else:
      bus = True
      oko = t + K
      cnt = 1
      ans += 1
  else:
    cnt = 1
    bus = True
    ans += 1
    oko = t + K
    
print(ans)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
a=sorted([int(input()) for _ in range(n)],reverse=True)
cnt=0
cnt2=1
while len(a) > 0:
    b=a.pop()
    cnt+=1
    if len(a)==0:
        break
    cnt2=1
    while cnt2<c:
        if a[-1]<=b+k:
            a.pop()
            cnt2+=1
            if len(a)==0:
                cnt2=1
                break
        else:
            cnt2=1
            break
print(cnt)

Submission status: Accepted

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

fast, cnt, ans = 0, 0, 0
for i in t:
    if fast + k < i or cnt == c:
        cnt = 0
    if cnt == 0:
        ans += 1
        fast = i
    cnt += 1
print(ans)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

    T.sort()
    ans = 0
    s = 0  # Time when the bus comes
    m = 0  # Current numbers of passengers
    for t in T:
        if m == 0:
            s = t
            m = 1
            ans += 1
        else:
            if t <= s + K:
                m += 1
            else:
                s = t
                m = 1
                ans += 1
        if m == C:
            m = 0

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
N,C,K = list(map(int,input().split()))
T = sorted([int(input()) for _ in range(N)])
ans = 1
count = 0
first = T[0]
for t in T:
    if t <= first+K and count < C:
        count += 1
    else:
        count = 1
        ans += 1
        first = t
print(ans)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()
ans = 1
cur = t[0]
cnt = 0
for i in t:
    if i > cur + k or cnt == c:
        ans += 1
        cnt = 1
        cur = i
    else:
        cnt += 1
print(ans)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])
ans = 0
bus = 0
pk = t[0] + k

for i in range(n):
    if bus == c or t[i] > pk:
        ans += 1
        bus = 1
        pk = t[i] + k
    else: 
        bus += 1
print(ans + 1)

Submission status: Accepted

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

bus = 1
lastPassenger = T[0]
waiting = 1
for t in T[1:]:
    if waiting < C and lastPassenger + K >= t:
        waiting += 1
    else:
        waiting = 1
        lastPassenger = t
        bus += 1

print(bus)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
t_lst = [int(input()) for _ in range(n)]
t_lst.sort()
ans = 0
cnt = 0
last = 0
if c == 1:
    print(n)
    exit()
for t in t_lst:
    if t > last:
        ans += 1
        last = t + k
        cnt = 1
    else:
        cnt += 1
        if cnt == c:
            last = 0
            cnt = 0
print(ans)

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


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

ans = 1
bus_time = T[0]
bus_num = 0
for i in range(N):
    if T[i] <= bus_time+K and bus_num < C:
        # 止まっているバスに乗る
        bus_num += 1
    else:
        # 新しいバスが必要
        bus_time = T[i]
        bus_num = 1
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


N, C, K = map(int, input().split())
T = [0]*N
for i in range(N):
    T[i] = int(input())

T.sort()

ans = 0
bus_time = -1
bus_num = 0
for i in range(N):
    # 新しいバス
    if bus_time == -1:
        bus_time = T[i]
        bus_num = 1
        ans += 1
    elif T[i] <= bus_time+K and bus_num <= C:
        bus_num += 1
    else:
        bus_time = T[i]
        bus_num = 1
        ans += 1

    if bus_num == C:
        bus_time = -1
        bus_num = 0
print(ans)

Submission status: Accepted

Solution code:
def main():
    n, c, k = list(map(int, input().split()))
    T = [int(input()) for _ in range(n)]
    T.sort()
    count = 0
    ans = 1
    t0 = T[0]
    for t in T:
        if t - t0 <= k:
            count += 1
        if count > c or t - t0 > k:
            ans += 1
            count = 1
            t0 = t
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

cnt = 0
res = 1
time = T[0]
for i in range(N-1):
    cnt += 1
    if cnt == C or time + K < T[i+1]:
        res += 1
        cnt = 0
        time = T[i+1]
print(res)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

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

    print(ans)

    
    
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,c,k = iim()
time = []
for _ in range(n):
    time.append(ii())

time.sort()

bus = 0
fst = time[0]
ans = 0
for item in time:
    if bus <= c-1 and item <= k+fst:
        bus += 1
    else:
        bus = 1
        ans += 1
        fst = item

print(ans if bus == 0 else ans+1)

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,c,k = iim()
time = []
for _ in range(n):
    time.append(ii())

time.sort()

bus = 0
fst = time[0]
ans = 0
for item in time:
    if bus <= c-1 and item <= k+fst:
        bus += 1
    elif bus > c-1:
        bus = 1
        ans += 1
        fst = item
    elif item-fst > k:
        bus = 1
        ans += 1
        fst = item
    

print(ans if bus == 0 else ans+1)

Submission status: Accepted

Solution code:
def main():
    import sys
    import heapq
    input = sys.stdin.readline
    N, C, K = [int(x) for x in input().strip().split()]
    T = []
    for _ in range(N):
        heapq.heappush(T, int(input()))
    
    k = 0
    c = 0
    ans = 0
    while T:
        t = heapq.heappop(T)
        if c % C == 0:
            k = t + K
            ans += (c > 0)
            c += 1
        elif t <= k:
            c += 1
        else:
            ans += 1
            c = 1
            k = t + K
    else:
        ans += (c > 0)

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, C, K, *T = map(int, open(0).read().split())
T = sorted(T)
ans = 0
curr = [T[0]]
for i in range(N - 1):
    if len(curr) < C and T[i + 1] - curr[0] <= K:
        curr.append(T[i + 1])
    else:
        ans += 1
        curr = [T[i + 1]]
print(ans + 1)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
  t[i]=int(input())
t.sort()
ans=1
temp=t[0]
tempc=1
for i in range(1,n):
  if temp+k<t[i] or tempc>=c:
    ans=ans+1
    temp=t[i]
    tempc=1
  else:
    tempc=tempc+1
print(ans)

Submission status: Accepted

Solution code:
n,c,k = map(int,input().split())
t = [int(input()) for nesya in range(n)]
t.sort()
bus = 0
wait = []
for i in range(n):
  wait.append(t[i])
  if wait[0] + k < t[i]:
    bus += 1
    wait = [t[i]]
  elif len(wait) == c:
    bus += 1
    wait = []
  elif wait[0] + k == t[i]:
    bus += 1
    wait = []
  if i == n-1 and len(wait) > 0:
    bus += 1
print(bus)

Submission status: Accepted

Solution code:
def main():
    n, c, k = map(int, input().split())
    customers = [int(input()) for i in range(n)]
    
    customers.sort()
    bus_count = 0
    in_bus = []

    for i in range(n):
        if len(in_bus) == 0:
            in_bus.append(customers[i])
        elif len(in_bus) < c and customers[i] <= in_bus[0] + k:
            in_bus.append(customers[i])
        else:
            bus_count += 1
            in_bus = []
            in_bus.append(customers[i])
    
    print(bus_count+1)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

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

    if C == 1:
        print(N)
        exit()

    cnt = 0
    ans = 0
    t0 = -10**10
    for t in T:
        if t0 + K < t:
            t0 = t
            cnt = 1
            ans += 1
        else:
            cnt += 1
            if cnt == C:
                cnt = 0
                t0 = -10**10
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
t = [int(input()) for _ in range(n)]
a = [0]*(n+1)
i = 0
j = 0
t = sorted(t)
while i < n:
    now = t[i]
    a[j] += 1
    i += 1
    while a[j] <c and i<n:
        if now<=t[i]<=now+k:
            a[j] += 1
        else:
            break
        i += 1
    j += 1
print(len([x for x in a if x != 0]))

Submission status: Accepted

Solution code:
N, C, K = [int(x) for x in input().split()]

times = [int(input()) for x in range(N)]
times.sort()

count = 0
minimum = None
passenger = 0

for t in times:
    passenger += 1
    if minimum  and (t - minimum) > K:
        count += 1
        minimum = t
        passenger = 1
    elif passenger == C:
        count += 1
        minimum = None
        passenger = 0
    elif minimum is None:
        minimum = t

if passenger:
    count += 1

print(count)

Submission status: Accepted

Solution code:
n,c,k,*t=map(int,open(0).read().split())
t.sort()
busstart=t[0]
passenger=0
buscount=0
for i in t:
    if i>busstart+k or passenger==c:
        busstart=i
        passenger=1
        buscount+=1
    else:
        passenger+=1
print(buscount+1)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
from collections import deque

t = [int(input()) for _ in range(n)]
t.sort()
t=deque(t)

ans = 1
bus=t[0]+k
cnt = 0

while t:
    i=t.popleft()
    if i>bus:
        bus=i+k
        ans+=1
        cnt=1
    elif cnt==c:
        bus=i+k
        ans+=1
        cnt=1
    else:
        cnt+=1

print(ans)

Submission status: Accepted

Solution code:
N,C,K=map(int,input().split())
from collections import deque
T=[int(input())for _ in range(N)]
T.sort()
T=deque(T)

ans=1
bus=T[0]+K
count=0
while T:
    i=T.popleft()
    if i>bus:
        bus=i+K
        ans+=1
        count=1
    elif count==C:
        bus=i+K
        ans+=1
        count=1
    else:
        count+=1
print(ans)

Submission status: Accepted

Solution code:
#AGC011-A Airport Bus
"""
時刻順にソート
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,c,k = map(int,readline().split())
t = []
for i in range(n):
    t.append(int(readline()))

t.sort()
res_k = t[0]
res_c = 0
ans = 0
for i in range(n):
    res_c += 1
    if i+1 < n:
        if t[i+1] - res_k > k:
            ans += 1
            res_c = 0
            res_k = t[i+1]
    if res_c == c:
        ans += 1
        if i+1 < n:
            res_k = t[i+1]
        res_c = 0

print(ans if res_c == 0 else ans + 1)

Submission status: Accepted

Solution code:
n,c,k = [int(x) for x in input().split()]
t = [int(input()) for _ in range(n)]
t.sort()
bus = c
f_bus = 0
ans = 0
for i in range(n):
    if t[i] > f_bus or bus == 0:
        ans += 1
        f_bus = t[i]+k
        bus = c-1
    else:
        bus -= 1

print(ans)

Submission status: Accepted

Solution code:
n,c,k = [int(x) for x in input().split()]
t = [int(input()) for _ in range(n)]
t.sort()
bus = c
f_bus = 0
ans = 0
for i in range(n):
    if t[i] > f_bus or bus == 0:
        ans += 1
        f_bus = t[i]+k
        bus = c-1
    else:
        bus -= 1

print(ans)

Submission status: Accepted

Solution code:
from collections import deque

N,C,K = map(int, input().split())

T_list = list() #左がもっとも早く着いた人

for i in range(N):
    T = int(input())
    T_list.append(T)

T_list.sort(reverse=False)

waiting_deque = deque(T_list)
ans = 0

while 1:
    if len(waiting_deque) != 0:
        ans += 1
        bus_passenger = list()
        bus_passenger.append(waiting_deque.popleft())
        while 1:
            if len(waiting_deque)!=0 and len(bus_passenger) < C and bus_passenger[0] + K >= waiting_deque[0]:
                bus_passenger.append(waiting_deque.popleft())
            else:
                #print(bus_passenger)
                break
    else:
        break

print(ans)

Submission status: Accepted

Solution code:
N, C, K = map(int, input().strip().split(" "))
t = sorted([int(input().strip()) for _ in range(N)])

bus = 0
idx = 0
while idx < N:
    bus_go = t[idx] + K
    tmp = 0
    while idx < N:
        if t[idx] <= bus_go:
            tmp += 1
            idx += 1
            if idx == N:
                break
            if tmp == C:
                bus += 1
                tmp = 0
                bus_go = t[idx] + K
        else:
            break
    if tmp > 0:
        bus += 1

print(bus)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
buscount=1
waiting=0
T=[]
for _ in range(n):
    t=int(input())
    T.append(t)
T=sorted(T)
mae_no_time=T[0]
noruhito=1
for i in range(1,n):
    waiting+=T[i]-mae_no_time
    noruhito+=1
    mae_no_time=T[i]
    if waiting>k or noruhito>c:
        buscount+=1
        waiting=0
        noruhito=1

print(buscount)

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
T = sorted(map(int, (input() for _ in range(N))))
ans = 0
count = 0
bus = None
for t in T:
    tk = t + K
    if bus is None or bus < t or count + 1 > C:
        bus = tk
        count = 0
        ans += 1
    count += 1
print(ans)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
t = sorted([int(input()) for _i in range(n)])+[float('inf')]

b = 0
time = t[0]
count = 0
for i in range(n+1):
    if t[i] > time+k or count == c:
        b += 1
        time = t[i]
        count = 0
    count += 1
print(b)

Submission status: Accepted

Solution code:
from collections import deque
n,c,k=map(int,input().split())
t=deque(sorted([int(input()) for i in range(n)]))
b=[]
b.append(t.popleft())
ans=0
while t:
    if len(b)==c or t[0]>b[0]+k:
        ans+=1
        b=[]
    b.append(t.popleft())
if len(b)>0:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
N,C,K = list(map(int,input().split()))
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
cnt = 0

Bus = 1
Capa = 0
first = T[0]
for i in range(N):
    t = T[i]
    if t-first>K or Capa+1>C:
        Bus+=1
        Capa = 1
        first = t
    else:
        Capa += 1
print(Bus)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n,c,k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    t.sort()
    res = 1
    time, hito = t[0], 0
    for i in range(n):
        if t[i] - time > k:
            time = t[i]
            res += 1
            hito = 1
        elif hito + 1 > c:
            time = t[i]
            res += 1
            hito = 1
        else:
            hito += 1

    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

t.sort()
ans = 0
now = 0
ter = -1
for i in range(n):
  if ter < t[i]:
    ans += 1
    ter = t[i]+k
    now = 1
  else:
    if(c<=now):
      ans+=1
      ter = t[i]+k
      now = 1
    else:
      now += 1
      
print(ans)

Submission status: Accepted

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

ans=0
wait=[]
for i in range(N):
    t=T[i]
    if len(wait)>0 and t-wait[0]>K:
        ans+=1
        wait=[]
    wait.append(t)
    if len(wait)==C:
        ans+=1
        wait=[]
if len(wait)>0:
    ans+=1
print(ans)