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:
N,C,K = map(int,input().split())
Ts = sorted([int(input()) for _ in range(N)])

#print(Ts)

ans = 0
firstFlag = True
passenger = []	#limit lastNum
for i in range(N):
	if firstFlag:
		passenger = [Ts[i] + K,C-1]
		firstFlag = False
		ans += 1
		#print("first",str(passenger),Ts[i],ans)
	
	if i+1 < N and passenger[0] < Ts[i+1]:
		#print("time over",str(passenger),Ts[i],ans)
		firstFlag = True
	elif passenger[1] <= 0:
		#print("full",str(passenger),Ts[i],ans)
		firstFlag = True
	else:
		#print("other",str(passenger),Ts[i],ans)
		passenger[1] -= 1

print(ans)

Submission status: Accepted

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

#print(Ts)

ans = 0
firstFlag = True
passenger = []	#limit lastNum
for i in range(N):
	if firstFlag:
		passenger = [Ts[i] + K,C-1]
		firstFlag = False
		ans += 1
		#print("first",str(passenger),Ts[i],ans)
	
	if passenger[1] <= 0:
		#print("full",str(passenger),Ts[i],ans)
		firstFlag = True
	elif i+1 < N and passenger[0] < Ts[i+1]:
		#print("time over",str(passenger),Ts[i],ans)
		firstFlag = True
	else:
		#print("other",str(passenger),Ts[i],ans)
		passenger[1] -= 1

print(ans)

Submission status: Accepted

Solution code:
from bisect import bisect_right


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

ans = 0
idx = 0
while idx < N:
    in_time_idx = bisect_right(t, t[idx] + K)
    if (in_time_idx - 1) - idx + 1 <= C:
        idx = in_time_idx
    else:
        idx += C
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
visitor, capacity, limit = map(int, input().split())

visitorList = []

for _ in range(visitor):
    arrivalTime = int(input())
    visitorList.append(arrivalTime)
    
visitorList.sort()
start = visitorList[0]
end = start + limit

count = 0
bus = 1

for j in visitorList:
    if start <= j <= end:
        count += 1
        if count <= capacity:
            continue
        else:
            bus += 1
            start = j
            end = j + limit
            count = 1
    else:
        bus += 1
        start = j
        end = j + limit
        count = 1
        
print(bus)

Submission status: Accepted

Solution code:
N,C,K = map(int,input().split())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
i = 0
ans = 0
while i < N:
    Ti = T[i]
    cnt = 0
    while i < N and T[i] <= Ti + K and cnt < C:
        i += 1
        cnt += 1
    ans += 1
print(ans)

Submission status: Accepted

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

p = 0
b = 0
for i in range(n):
    t = T[i]
    if p == 0:
        w = t
    p += 1

    if t - w > k:
        b += 1
        p = 1
        w = t    
    elif p == c or t - w == k:
        b += 1
        p = 0

    if i == n - 1 and p > 0:
        b += 1
    #print(t, w, p, b)
print(b)

Submission status: Accepted

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

tmp_c = 0
bus_cnt = 0
wait_lmt = 0
for i,T in enumerate(Ts):
    if tmp_c == 0:
        wait_lmt = T + K
    
    if T <= wait_lmt:
        tmp_c += 1
    
    if i == len(Ts)  - 1 or Ts[i+1] > wait_lmt or tmp_c == C:
        tmp_c = 0
        bus_cnt += 1

print(bus_cnt)

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 = []
for i in range(N):
    T.append(int(input()))
T.sort()
cur = T[0]
bus = 0
limit = 0
for i in range(N):
    if i != N-1:
        if limit <= C-1:
            if T[i] <= cur+K:
                limit += 1
            else:
                bus += 1
                limit = 1
                cur = T[i]
        else:
            bus += 1
            limit = 1
            cur = T[i]
    else:
        if limit <= C-1:
            if T[i] <= cur+K:
                bus += 1
            else:
                bus += 2
        else:
            bus += 2
print(bus)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
from collections import deque, defaultdict

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, c, k = LI()
    T = deque(sorted([II() for _ in range(n)]))

    p = T.popleft()
    t = p + k
    res = 0
    while T:
        cnt = 1
        while T and cnt < c and T[0] <= t:
            cnt += 1
            T.popleft()
        res += 1
        p = 0
        if T:
            p = T.popleft()
            t = p + k

    if p:
        res += 1

    return res


print(main())

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
T = sorted([int(input()) for i in range(N)])
s = 0
array = [T[0]]
arrays = []
for i in range(1, N):
    if ((T[i] - T[s]) <= K) and (len(array) < C):
        array.append(T[i])
    else:
        arrays.append(array)
        array = [T[i]]
        s = i
print(len(arrays + [array]))

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
T = sorted([int(input()) for i in range(N)])
array = [T[0]]
arrays = []
s = 0
for i in range(1, len(T)):
    if ((T[i] - T[s]) <= K) and len(array) < C:
        array.append(T[i])
    else:
        arrays.append(array)
        array = [T[i]]
        s = i
print(len(arrays + [array]))

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Grand_Contest011-A
#  TODO https://atcoder.jp/contests/agc011/tasks/agc011_a

def solveProblem(personNumber,maxPerson,waitMaxTime,reachTime):
	needBas = 1
	reachTime.sort()
	nowTime = reachTime[0]
	nowPassenger = 0
	for i in  range(0,len(reachTime),+1):
		if nowPassenger < maxPerson and reachTime[i] <= nowTime + waitMaxTime:
			nowPassenger = nowPassenger+1
		else:
			needBas = needBas+1
			nowTime = reachTime[i]
			nowPassenger = 1
	answer = needBas
	return answer


if __name__ == '__main__':
	N,C,K = map(int,input().strip().split(' '))
	dataGetPerson = range(0,N,+1)
	reachTime = []
	for _ in dataGetPerson:
		reachTime.append(int(input()))
	solution = solveProblem(N,C,K,reachTime)
	print("{}".format(solution))

Submission status: Accepted

Solution code:
n,c,k = (int(i) for i in input().split())
t = sorted(int(input()) for i in range(n))
ans = pas = time = 0
for j in t:
  if j > time or pas >= c:
    ans += 1
    time = j + k
    pas = 1
  elif j <= time and pas < c:
    pas += 1
print(ans)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
t = [int(input()) for _ in range(n)]
t.sort()
count = 1
num = 0
time=t[0]
for i in range(n):
    if num < c and t[i] <= time+k:
        num+=1
    else:
        count+=1
        time=t[i]
        num=1
print(count)

Submission status: Accepted

Solution code:
n,c,k = map(int, input().split())
tt = sorted([int(input()) for _ in range(n)])
# print(tt)
ans = 0
limit = 0
buss = 1
for i,t in enumerate(tt):
    if buss == c or t>limit:
        # print('NEED MORE BUSS')
        ans += 1
        buss = 1
        limit = t+k
    else:
        buss +=1
    # print(ans, buss, t, limit)
print(ans)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]
t.sort()
res=0
i1=0
while(i1<n):
    i2=0
    j=t[i1]+k
    if i1==n-1:
        res+=1
        break
    while(i1+i2<len(t) and t[i1+i2]<=j and i2<c):
        i2+=1
    res+=1
    i1+=i2
print(res)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
t=sorted([int(input()) for i in range(n)])
ans=0
j=0
e=0
for i in t:
    if j==0:
        j=1
        e=i+k
        ans+=1
    elif e<i:
        j=1
        e=i+k
        ans+=1
    else:
        j+=1
    if j==c:
        j=0
print(ans)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n,c,k=map(int,input().split())
T=[int(input()) for _ in range(n)]
T.sort()
cnt=1
num=0
time=T[0]
for i in range(n):
    if num<c and T[i]<=time+k:
        num+=1
    else:
        cnt+=1
        time=T[i]
        num=1
print(cnt)

Submission status: Accepted

Solution code:
n, c, k = list(map(int, input().split()))
tlist = [int(input()) for i in range(n)]
tlmt = None
onb = 0
bnum = 1
for t in sorted(tlist):
  if tlmt is None:
    tlmt = t + k
  if t <= tlmt and onb < c:
    onb += 1
  else:
    tlmt = t + k
    onb = 1
    bnum += 1

print(bnum)

Submission status: Accepted

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

num = t[0]
count = 1
ans = 0
for i in range(1, n):
    if t[i] <= num + k and count + 1 <= c:
        count += 1
    else:
        count = 1
        num = t[i]
        ans += 1

ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,c,k = li()
t = [ni() for _ in range(n)]

t.sort()

ans = 0
people = 0
isfirst = True
for ti in t:
    if isfirst:
        first = ti
        people = 1
        isfirst = False
        
    else:
        if ti <= first + k and people < c:
            people += 1
            
        else:
            ans += 1
            
            people = 1
            first = ti

print(ans+1)

Submission status: Accepted

Solution code:
def inpl(): return list(map(int, input().split()))

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

B = []
ans = 0
for i in range(N):
    t = T[i]
    if len(B) == 0:
        B.append(t)
    elif t <= B[0] + K:
        B.append(t)
    else:
        B = [t]
        ans +=1
    
    if len(B) == C:
        B = []
        ans += 1

ans += len(B) > 0

print(ans)

Submission status: Accepted

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

cap = C-1
dep = T[0] + K
ans = 1
for t in T[1:]:
    if cap and t <= dep:
        cap -= 1
    else:
        cap = C-1
        dep = t + K
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n,c,k = map(int,input().split())
t = [int(input()) for i in range(n)]
t.sort()
cnt = 0
i = 0
while t != []:
    if len(t) == 1:
        cnt += 1
        break
    while t[i] - t[0] <= k:
        i += 1
        if i == len(t) :
            break
        if i == c:
            break
    del t[:i]
    cnt += 1
    i = 0
print(cnt)

Submission status: Accepted

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

T.sort(reverse=True)

count = 0
while T:
    limit = T[-1]+K
    count += 1
    for i in range(C):
        if T and T[-1] <= limit:
            T.pop()
        else:
            break

print(count)

Submission status: Accepted

Solution code:
#横にn個入力
n, c, k = map(int, input().split())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
t = [int(m) for m in d]#int型に直す

t.sort()
current = 0
ans = 0
psn = 0
getonpsn = 0
for i in range(n):
    psn += 1
    if i == 0:
        current = t[i]
    if t[i] - current > k:
        psn -= 1
        ans += psn // c
        getonpsn += (psn // c) * c
        if psn // c == 0:
            getonpsn += psn
            ans += 1
            psn = 0
            #if getonpsn != n:
            current = t[getonpsn]
            if i == n - 1:
                    ans += 1
        elif getonpsn != n:#iminai
            current = t[getonpsn]
            if i == n - 1:
                if t[i] - current > k:
                    ans += 2
                else:
                    ans += 1

        psn = psn % c


        psn += 1
    elif i == n - 1:
        ans += (psn + c + 1) // c


print(ans)

Submission status: Accepted

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

bus = 0
i = 0
while i < n:
  base = i
  bus += 1
  passenger = 0
  while i < n and t[i] <= t[base] + k and passenger + 1 <= c:
    passenger += 1
    i += 1
print(bus)

Submission status: Accepted

Solution code:
def solve(N, C, K, Ts):
    Ts.sort()
    count = 0
    ans = 0
    time = 0
    for t in Ts[::-1]:
        if count >= C or t < time - K:
            ans += 1
            count = 0
            time = 0
        count += 1
        if time == 0:
            time = t
    if count > 0:
        ans += 1
    return ans


if __name__ == "__main__":
    N, C, K = tuple(map(int, input().split(" ")))
    Ts = [int(input()) for _ in range(N)]
    print(solve(N, C, K, Ts))

Submission status: Accepted

Solution code:
n,c,k,*t=map(int,open(0).read().split())
t.sort(reverse=1)
a=0
while t:
  h=t.pop()
  i=h
  j=1
  while t and j<c and i-h<k:
    i=t.pop()
    j+=1
  if i-h>k:
    t.append(i)
  a+=1
print(a)

Submission status: Accepted

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

T = sorted(T)
j = 0
ans = 0
while j < N:
    t = T[j]
    ret = bisect.bisect_right(T, t+K, lo=j, hi=min(j+C, N))
    if ret-j > C:
        ret = C
    j += ret-j
    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, C, K = MAP()
tN = [INT() for i in range(N)]

tN.sort()
ans = 0
bus = 0
timer = K
for i in range(N):
    if 1 <= bus <= C-1:
        timer -= tN[i] - tN[i-1]
        # 時間が過ぎていたら今のバスは出発済にする
        if timer < 0:
            ans += 1
            bus = 0
            timer = K
    # 1,2人目は普通に乗せる
    if 0 <= bus <= C-2:
        bus += 1
    # 3人目が乗ったら出発
    elif bus == C-1:
        ans += 1
        bus = 0
        timer = K
# 未出発のバスを出発させる
if bus != 0:
    ans += 1
print(ans)

Submission status: Accepted

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

li.sort()
ans = 1
cnt = 1
t0 = li[0]
for t in li[1:]:
    if t > t0 + k or cnt == c:
        ans += 1
        t0 = t
        cnt = 1
    else:
        cnt += 1

print(ans)

Submission status: Accepted

Solution code:
n,c,k = list(map(int, input().split()))
ts = [int(input()) for i in range(n)]
ts.sort()
start = ts[0] + k
cnt = 0
ans = 1
for t in ts:
    # 乗れるので乗せる
    if t <= start and cnt < c:
        cnt += 1
    # 乗れるバスがないとき、次のバスを作る
    else:
        start = t+k
        cnt = 1
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

x=[]
for i in range(n):
    x.append(int(input()))
        
    
x.sort()

count=1

bus_count=0

for j in range(n-1):
    bus_count+=1
    if(x[j+1-bus_count]+k<x[j+1] or bus_count==c):
        count+=1
        bus_count=0
        
print(count)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
l=[int(input())for i in range(a)]
l.sort()
p=0
k=0
d=0
for i in range(a):
    q=l[i]
    if p==b or d<q:
        d=q+c
        k+=1
        p=1
    else:
        p+=1
print(k)

Submission status: Accepted

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

ans = 0
capa = 0
dept = -1
for t in sorted(T):
    if t > dept or capa == 0:
        ans += 1
        dept = t+K
        capa = C-1
    else:
        capa -= 1
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(200000)


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


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


N, C, K = il()
T = sorted(imi(N))
ll = []
c = 1
ll = [T[0]]
for t in T[1:]:
    if len(ll) == C or ll[0] + K < t:
        ll = []
        c += 1
    ll.append(t)
print(c)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
t=[int(input()) for _ in [0]*n]
t.sort()
b=1
h=0
d=t[0]
for i in range(n):
  if(h<c and t[i]-d<=k):
    h+=1
  else:
    b+=1
    h=1
    d=t[i]
print(b)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
t=[int(input()) for _ in [0]*n]
t.sort()
t=t+[0]
b=1
h=0
d=t[0]
for i in range(n):
  if(h<c and t[i]-d<=k):
    h+=1
  else:
    b+=1
    h=1
    d=t[i]
print(b)

Submission status: Accepted

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

T = []

for i in range(N):
    tmp = int(input())
    T.append(tmp)
    
T.sort()
    
ans = 1
now = 1
now_time = T[0]

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

Submission status: Accepted

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

inputs.sort()

start = inputs[0]
capa = 1
ans = 1
for i in range(1, N):
    capa += 1
    if start + K < inputs[i] or capa > C:
        ans += 1
        capa = 1
        start = inputs[i]

print(ans)

Submission status: Accepted

Solution code:
N,C,K=map(int,input().split())
T=[]
for i in range(N):
    p=int(input())
    T.append(p)
  
ans = 1
T = sorted(T)
ind = 0
 
for i in range(len(T)):
    if T[i] > T[ind]+K:
        ans += 1
        ind = i
    elif i >= ind + C:
        ans += 1
        ind = i
print(ans)

Submission status: Accepted

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

ANS=1
B=1
T=P[0]
for j in range(1,N):
    if K<(P[j]-T):
        ANS+=1
        B=1
        T=P[j]
    elif B<C:
        B+=1
    elif B>=C:
        ANS+=1
        B=1
        T=P[j]

print(ANS)

Submission status: Accepted

Solution code:
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()
num = 1
begin = 0
for j in range(100000):
    for i in range(begin + 1,N):
        wait = T[i] - T[begin]
        if wait > K or i - begin + 1> C:
            num += 1
            begin = i
            break
    else:
        break
print(num)

Submission status: Accepted

Solution code:
N,C,K=map(int,input().split())
A=[]
for i in range(N):
    a=int(input())
    A.append(a)
A.sort()
k=K
a=0
c=C-1
j=1
while j<N:
    k-=A[j]-A[j-1]
    c-=1
    if k>=0 and c>=0:    
        j+=1
    else:     
        a+=1
        c=C-1
        k=K
        j+=1
print(a+1)

Submission status: Accepted

Solution code:
N,C,K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
tmp = T[0]
ans = 0
cnt = 1
for i in range(1, N):
    cnt += 1
    if T[i]-tmp>K:
        ans += 1
        cnt = 1
        tmp = T[i]
    elif cnt>C:
        ans += 1
        cnt = 1
        tmp = T[i]
print(ans+1)

Submission status: Accepted

Solution code:
n, c, k = [int(i) for i in input().split()]
# 合計n人,バス容量c人,到着後k以内に乗る
t = [0 for _ in range(n)]
first = 0  # バス待ちの先頭人の到着時刻
num = 0  # バス待ちの人の数
bass = 0
for i in range(n):
    # 乗客iが到着する時刻
    t[i] = int(input())
t = sorted(t)
for i in range(n):
    # 乗客iが到着する時刻
    if num == 0:
        first = t[i]
        num += 1
    elif first + k < t[i]:
        # print("timeup t:{}".format(t[i]))
        bass += 1
        first = t[i]
        num = 1
    elif num == c:
        # print("over people t:{}".format(t[i]))
        bass += 1
        first = t[i]
        num = 1
    else:
        num += 1
print(bass + 1)
# 必要なバスの台数を出力
# 単純に到着がc人になるか,
# 先頭の人が到着してからk秒たったらバスを出す

Submission status: Accepted

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

T = [int(input()) for i in range(N)]

T.sort()
A = T[0]
SUM = 1
ans = 0
for i in range(1, N):
    SUM += 1
    if T[i] - A > K:
        ans += 1
        SUM = 1
        A = T[i]
    elif SUM > C:
        ans += 1
        SUM = 1
        A = T[i]

        
print(ans+1)

Submission status: Accepted

Solution code:
N, C, K, *T = map(int, open(0).read().split())
T.sort()
head, tail = 0, 1  # half-open interval
cnt = 0
while tail <= N:
    while tail < N and tail - head < C and T[head] + K >= T[tail]:
        tail += 1
    cnt += 1
    head, tail = tail, tail + 1
print(cnt)

Submission status: Accepted

Solution code:
N, C, K = [int(_) for _ in input().split()]
times = sorted([int(input()) for _ in range(N)], reverse=True)
count = 0
while times:
    t = times.pop()
    count += 1
    num = 1
    while times:
        if times[-1] <= t + K and num < C:
            times.pop()
            num += 1
        else:
            break
print(count)

Submission status: Accepted

Solution code:
N, C, K = [int(_) for _ in input().split()]
times = sorted([int(input()) for _ in range(N)])
count = 0
while times:
    t = times.pop(0)
    count += 1
    num = 1
    while times:
        if times[0] <= t + K and num < C:
            times.pop(0)
            num += 1
        else:
            break
print(count)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
x=[0]*2
ans=0
l=[]
for i in range(n):
    n=int(input())
    l.append(n)
l.sort()


for n in l:
    if x[0]==0 and c>1:
        x=[n,1]
    elif x[0]==0:
        ans+=1
    elif n>x[0]+k:
        ans+=1
        x=[n,1]
    elif x[1]+1<c:
        x[1]+=1
    else:
        ans+=1
        x=[0,0]
print(ans+[0,1][x[0]>0])

Submission status: Accepted

Solution code:
def inpl(): return [int(i) for i in input().split()]

N, C, K = inpl()
A = []
for _ in range(N):
    A.append(int(input()))
A = list(sorted(A))
bus = 0
st = -K-1
nop = 0
for i in A:
    if st + K < i or nop == C:
        bus += 1
        st = i
        nop = 1
    else:
        nop += 1
print(bus)

Submission status: Accepted

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

ans = 0
space = C
dept = 0
for t in T:
    if t <= dept and space > 0:
        space -= 1
        continue
    dept = t+K
    space = C-1
    ans += 1
print(ans)

Submission status: Accepted

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

p = 0 #t[i]を処理し終えた時点で、待機してる人数
w = t[0] #t[i]を処理し終えた時点で、待機してる人の中で一番最初から待ってる人の時間

res = 0 #t[i]を処理し終えた時点で、用いたバスの数
for i in range(n):
    p += 1
    if t[i]-w > k:
        p = 1
        res += 1
        w = t[i]
        if i == n-1:
            res += 1
    elif c == p:
        p = 0
        res += 1
        if i != n-1:
            w = t[i+1]
    
    else:
        if i == n-1:
            res += 1

print(res)

Submission status: Accepted

Solution code:
import sys

def main() -> None:
    n, c, k = map(int, input().split())
    t = [int(sys.stdin.readline()) for _ in range(n)]
    ans = wait_start = wait_people = 0

    for ti in sorted(t):
        if ti - wait_start > k or wait_people == c:
            wait_people = 0
        wait_people += 1

        if wait_people == 1:
            wait_start = ti
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main() -> None:
    n, c, k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    ans = wait_start = wait_people = 0

    for ti in sorted(t):
        if ti - wait_start > k or wait_people == c:
            wait_people = 0
        wait_people += 1

        if wait_people == 1:
            wait_start = ti
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n,c,k = map(int, input().split())
k *= 2
t = []
for _ in range(n):
    t.append(int(input())*2)
t.sort()
# print(t)
res = 0
s = []
for x in t:
    if len(s)==0:
        s.append(x)
    else:
        # print(x,s,x-s[0])
        if x-s[0]>k:
            while len(s)>0 and x-s[0]>k:
                res += 1
                s = s[c:]
            s.append(x)
        elif len(s)+1>c:
            res += 1
            s = s[c:]
            s.append(x)
        else:
            s.append(x)
# print(s)
if len(s)>0:
    res += 1
print(res)

Submission status: Accepted

Solution code:
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T = sorted(T)
counter = 0
ans = 1
A = []
while counter != N :
    if len(T) > 0 and len(A) < C and ((len(A) == 0) or (T[0] <= A[0] + K)) :
        A.append(T[0])
        T.pop(0)
        counter += 1
    else :
        A = []
        ans += 1
print(ans)

Submission status: Accepted

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

bus = 0
kyaku = 0
dep_time = 0
for t in T:
    if t > dep_time or kyaku == C:
        dep_time = t + K
        kyaku = 1
        bus += 1
    else:
        kyaku += 1

print(bus)

Submission status: Accepted

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

Bus, Cap = 1, 1
Lim = T[0]+K
for i in range(N-1):
    if T[i+1] <= Lim:
        if Cap < C:
            Cap += 1
        else:
            Bus += 1
            Cap = 1
            Lim = T[i+1] + K
    else:
        Bus += 1
        Cap = 1
        Lim = T[i+1] + K
print(Bus)

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
ans = 0
first = T[0]
arrived = 0
for t in T:
    if first + K < t or arrived == C:
        ans += 1
        arrived = 0
        first = t
    arrived += 1
print(ans + (arrived > 0))

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
T = []
for _ in range(N):
    T.append((int(input()), False))
    T.append((T[-1][0] + K, True))
T.sort(key=lambda x: (x[0], x[1]))
ans = 0
arrived = 0
head = 0
for t, bo in T:
    if arrived == 0 and not bo:
        head = t
    arrived += not bo
    if (bo and arrived > 0 and head <= t - K) or arrived == C:
        arrived = 0
        ans += 1
        head = 2000000009
if arrived > 0:
    ans += 1
print(ans)

Submission status: Accepted

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

ans = 0
bus = []

for t in times:
    if len(bus) in (0,c) or bus[0] + k < t:
        bus = []
        ans += 1
    bus.append(t)

print(ans)

Submission status: Accepted

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

T.sort()

for t in T:

    if passenger == 0:
        #乗客が０なので一人目としてストックし、バスを確保
        time = t
        passenger = 1
        count += 1

    #２人目以降、定員以内
    elif 1 <= passenger < C:
        if t - time <= K:
            #乗って問題がないので追加
            passenger += 1
        else:       
            #一人目が時間オーバーになるのでバスを出して一人目になる
            count += 1
            passenger = 1
            time = t
            
    #２人目以降、定員オーバー
    else:
        #定員オーバーになるのでバスを出して一人目になる
        count += 1
        passenger = 1
        time = t
        
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

t_list.sort()

count = 0
passenger = 0
time = 0

for t in t_list:
    if passenger == 0:
        passenger += 1
        count += 1
        time = t
    elif 1 <= passenger < C:
        if t - time <= K:
            passenger += 1
        else:
            passenger = 1
            count += 1
            time = t
    else:
        passenger = 1
        count += 1
        time = t

print(count)