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:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,c,k = na()
t = []

for i in range(n):
    u = ni()
    t.append(u)

t.sort()

now = t[0]
p = 1
ans = 1

for i in t:
    if i-now > k or p > c:
        p = 2
        now = i
        ans += 1
    else:
        p += 1

print(ans)

Submission status: Accepted

Solution code:
n,c,k = map(int,input().split())
t = 0
cnt = c
ans = 0
T = [int(input()) for _ in range(n)]
T.sort()
for i in range(n):
    if cnt == c or T[i] > t:
        ans += 1
        t = T[i] + k
        cnt = 1
    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
i = 0
while i < N:
    p = 0
    lm = T[i] + K
    while i < N and p < C and lm >= T[i]:
        p += 1
        i += 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)]

p = 0
r = 0
cnt = 1

T.sort()

for i in range(len(T)):
    if p == 0:
        p = 1
        q = T[i]
        r = 1
    elif p == 1 and q + K >= T[i] and r < C:
        r += 1
    else:
        cnt += 1
        p = 1
        q = T[i]
        r = 1

print(cnt)

Submission status: Accepted

Solution code:
def main():
    n,c,k=map(int,input().split())
    t=[]
    for i in range(n):
        ti=int(input())
        t.append(ti)
    t.sort()
    ans=0
    i=0
    while i<n:
        j=1
        while j<c and i+j<n:
            if t[i+j]>t[i]+k:
                break
            j+=1
        ans+=1
        i+=j
    print(ans)
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest

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

    t.sort()
    ans = 1
    bus_base = t[0] + k
    cnt_bus = 0

    for i in range(n):
        if cnt_bus == c:
            cnt_bus = 0
            bus_base = t[i] + k
            ans += 1

        if t[i] <= bus_base:
            cnt_bus += 1
            continue
        else:
            bus_base = t[i] + k
            ans += 1
            cnt_bus = 1

    print(ans)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 3 5
1
2
3
6
12"""
        output = """3"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """6 3 3
7
6
2
8
10
6"""
        output = """3"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
ttt = [int(input()) for _ in range(n)]
ttt.sort()
ans = 0
waiting_count = 0
waiting_first = -1

for t in ttt:
    if waiting_first == -1:
        waiting_count = 1
        waiting_first = t
    elif waiting_first + k < t:
        ans += 1
        waiting_count = 1
        waiting_first = t
    else:
        waiting_count += 1
    if waiting_count >= c:
        ans += 1
        waiting_count = 0
        waiting_first = -1
if waiting_count:
    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()
bus = 0
limit = t[0] + k
passenger = 0

"""
最初の人のリミットが来るor定員を超える→バス追加
"""
# print("------")
for i in range(n):
    if limit < t[i]:
        # print(t[i])
        bus += 1
        passenger = 0
        if i+1 < n:
            limit = t[i] + k
    
    passenger += 1

    if passenger == c:
        # print(t[i])
        passenger = 0
        bus += 1
        if i+1 < n:
            limit = t[i+1] + k

if passenger > 0:
    bus += 1

print(bus)

Submission status: Accepted

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

c = 0
l = float('inf')
result = 0
for i in range(N):
    t = T[i]
    if t > l:
        result += 1
        l = float('inf')
        c = 0
    if c == 0:
        l = t + K
    c += 1
    if c == C:
        result += 1
        l = float('inf')
        c = 0
if c != 0:
    result += 1
print(result)

Submission status: Accepted

Solution code:
n,c,k,*t=map(int,open(0).read().split())
t=sorted(t)
cnt=0
ans=1
x=t[0]
for i in range(n):
  cnt+=1
  if t[i]-x>k or cnt>c:
    x=t[i]
    ans+=1
    cnt=1
print(ans)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
t=[]
for _ in range(n):
  t.append(int(input()))
if c==1:
  print(n)
  exit()

t.sort()
time=0
p=0
taiki=0
ans=0
for i in range(n):
  if taiki==0:
    p=t[i]
    time=0
    taiki+=1
    continue
  taiki+=1
  time+=t[i]-p
  p=t[i]
  if time > k :#i-1番目までの客をバスに乗せる。i番目の客は待機
    ans+=1
    taiki=1
    time=0
  elif taiki==c:#i番目までの客をバスに乗せる
    ans+=1
    taiki=0
ans += 1 if taiki > 0 else 0
print(ans)

Submission status: Accepted

Solution code:
from queue import Queue

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

# T = [[出発時刻, 到着時刻], ...]
T = [[0, 0] for _ in range(N)]
for i in range(N):
    t = int(input())
    T[i][0] = t + K
    T[i][1] = t

T.sort()
que = Queue()
for t in T:
    que.put(t)

ans = 0
dest = -1
cap = 0

while not que.empty():
    td, ta = que.get()

    # 新しいバス
    if cap == 0:
        dest = td
        cap = 1
    # 待っているバスがいる
    elif ta <= dest:
        cap += 1
    # バスがもう待てない
    else:
        ans += 1
        dest = td
        cap = 1

    # 定員に達してしまったら出発させる
    if cap == C:
        ans += 1
        cap = 0

# バスに乗客が残っていたら出発
if cap > 0:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
import collections

N, C, K = map(int, input().split())
T = collections.deque()
for _ in range(N):
    T.append(int(input()))
T = sorted(T)
T = collections.deque(T)
#print(T)
ans = 0

while T:
    time = T[0] + K
    cnt = 0
    while T[0] <= time:
        T.popleft()
        cnt += 1
        if cnt >= C:
            break
        if not T:
            break
    ans += 1
print(ans)

Submission status: Accepted

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

b_cnt=0
p_cnt=0
time=Tn[0]+K
for t in Tn:

    # print(time, p_cnt)
    if (time < t) or (p_cnt >= C) :
        # バス出発
        b_cnt+=1
        p_cnt=0
        time=t+K
        # print("ride", b_cnt)
    p_cnt+=1
else:
    b_cnt+=1

print(b_cnt)

Submission status: Accepted

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

cnt = 1
time = 0
capa = 1
pre = T[0]

for i in range(1, N):
    capa += 1
    time += T[i]-pre
    if capa>C or time>K:  # 次のバスを用意
        cnt += 1
        time = 0
        capa = 1

    pre = T[i]

print(cnt)

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()
ans=0
tmp=0
count=0
for i in range(N):
    #print(count)
    if i==0:
        dead=T[i]+K
        count=1
        continue
    count+=1
    if T[i]>dead or count>C:
        ans+=1
        dead=T[i]+K
        count=1
        continue
ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys


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


sys.setrecursionlimit(10 ** 9)


def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    T.sort()
    answer = 0
    cst = C
    time = 0
    for t in T:
        if (time + K >= t) and (cst + 1 <= C):
            cst += 1
        else:
            answer += 1
            time = t
            cst = 1

    print(answer)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ind = 0
cnt = 0
while(ind<n):
    time = end[ind]
    for i in range(1,c+1):
        next_ind = ind + i
        if next_ind==n or start[next_ind]>time:
            break
    ind = next_ind
    cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
tmp = {"f": 0, "num": c}

for x in t:
    if tmp["f"] >= x and tmp["num"] > 0:
        tmp["num"] -= 1
    else:
        ans += 1
        tmp["num"] = c-1
        tmp["f"] = x+k


print(ans)

Submission status: Accepted

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

ans = 0
time = 0
j = c
for i in t:
    if time>=i and j>0:
        j -= 1
    else:
        ans += 1
        j = c-1
        time = i+k

print(ans)

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
T = [0]*N
cnt = 1
bus = 1
for i in range(N):
    T[i] = int(input())
T.sort()
tmp = T[0]+K
for i in range(1, N):
    if(cnt == 0):
        bus += 1
        cnt = 1
        tmp = T[i]+K
        continue
        
    if(T[i] <= tmp and cnt < C):
        cnt += 1
        if(cnt == C):
            cnt = 0
    else:
        cnt = 1
        bus += 1
        tmp = T[i]+K
print(bus)

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=sorted(t)

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

for i in range(n):
  if cnt==c or time<t[i]:
    cnt=1
    ans+=1
    time=t[i]+k
  else:
    cnt+=1
    
print(ans)

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
Tlist = sorted([int(input()) for _ in range(N)])
ans = 0
now = 1
start = Tlist[0]
for t in Tlist[1:]:
    if now == C:
        ans += 1
        start = t
        now = 1
    else:
        if t - start <= K:
            now += 1
        else:
            ans += 1
            start = t
            now = 1
print(ans+1)

Submission status: Accepted

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

t_list = []
for i in range(n):
    tmp = int(input())
    t_list.append(tmp)

t_list.sort()
#print(t_list)

ans = 0
tmp = 0
pass_list = []
for t in t_list:
    #print(t)
    #print(pass_list)
    # 最初の乗客
    if len(pass_list) == 0:
        # バス追加
        ans += 1
        # 一番古い乗客の時間をメモ
        tmp = t
        # バスに乗せる
        pass_list.append(t)
        

    else:
        # 一番古い乗客の待ち時間が長い場合新しいバスを用意して乗せる
        if (t - tmp) > k:
            pass_list = []
            #print('バス追加1')
            ans += 1
            # 一番古い乗客の時間をメモ
            tmp = t

            pass_list.append(t)

        # バスに乗せる
        else:
            pass_list.append(t)

    # バスの定員が一杯の場合も新しいバスを用意する
    if len(pass_list) == c:
        pass_list = []
        #print('バス追加2')
        
print(ans)

Submission status: Accepted

Solution code:
#ARC007-B
if False:
    N,M=map(int,input().split())
    case=[i for i in range(N+1)]
    for _ in range(M):
        now=int(input())
        i=case.index(now)
        case[i]=case[0]
        case[0]=now
        # print(case)
    for i in range(1,N+1):
        print(case[i])

#ABC004-C (0408)
if False:
    N=int(input())-1
    N=N%30
    ans=list(range(1,7))
    for i in range(N+1):
        ans[i%5],ans[i%5+1]=ans[i%5+1],ans[i%5]
        # print(ans)
    print(''.join(map(str,ans)))

#AGC011-A (0408)
if True:
    N,C,K=map(int,input().split())
    T=[int(input()) for _ in range(N)]
    T.sort()
    cnt=1
    pas=1 # 乗客数
    tim=K+T[0] # departure time
    # print(T)
    for i in range(1,N):
        t=T[i]
        if tim<t or pas>=C:
            cnt+=1
            tim=t+K
            pas=1
        else:
            pas+=1
        # print(tim,pas,cnt)
    print(cnt)

Submission status: Accepted

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

first = T[0]
count = 0
res = 0
for i in range(N):
    if count < C and T[i] <= first + K:
        count += 1
    else:
        res += 1
        first = T[i]
        count = 1
print(res + 1)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
T = [int(input()) for _ in range(n)]
T.sort()
cnt = 0
ans = 1
t = T[0]
for i in range(n):
    cnt += 1
    if cnt > c or T[i] > t + k:
        ans += 1
        cnt = 1
        t = T[i]
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
mem=1
s=T[0]

for i in range(N):
    if T[i]>s+K or mem>=C:
        ans+=1
        s=T[i]
        mem=1
    else:
        mem+=1
print(min(ans,N))

Submission status: Accepted

Solution code:
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 = sorted([int(readline()) for i in range(n)])
cnt = 0
ans = 1
time = t[0] + k
for i in range(n):
    if cnt >= c or time < t[i]:
        ans += 1
        cnt = 0
        time = t[i] + k
    cnt += 1
print(ans)

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,c,k = m()

t = []

for i in range(n):
    t.append(onem())
t.sort()

po = 1

jo = 1

ti = t[0] + k

for i in range(1,n):
    on = t[i]
    if ti < on:
        po += 1
        jo = 1
        ti = on + k
    else:
        if jo + 1 <= c:
            jo += 1
        else:
            po += 1
            jo = 1
            ti = on + k
print(po)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])
l = 0
m = 0
ans = 0
for i in range(n):
    if l == 0:
        m = t[i]
        l += 1
    elif l < c:
        if m + k >= t[i]:
            l += 1
        else:
            ans += 1
            l = 1
            m = t[i]
    else:
        ans += 1
        l = 1
        m = t[i]
ans += 1
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, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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

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_limit >= T[i]:  # 乗れる
		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())
T = sorted([int(input()) for _ in range(N)])
cnt = 0
while T:
    T_min = T[0]
    for _ in range(C):
        if T[0] <= T_min + K:
            T.pop(0)
            if not T:
                break
        else:
            break
    cnt += 1
print(cnt)

Submission status: Accepted

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

#print("T:",T)
#print("U:",U)

j=0
k=0
p=[]  #居る人
bus=0
t=0

while k<N:
  #print(t,"j=",j,"k=",k)
  if j<N:
    if T[j]<=U[k]:
      #print("  T[j]",T[j],"<=U[k]",U[k])
      p.append(j)
      t=T[j]
      j +=1
      #print(t,"人数+1して",len(p))
      if len(p)>=C:
        #print(p,"人数max")
        k=max(p)+1
        p=[]
        #print(t,"バス発車。人数は",len(p),"k=",k)
        bus +=1
    else:
      #print("  T[j]",T[j],">U[k]",U[k])
      t=U[k]
      k=max(p)+1
      #print(p,"時間max")
      p=[]
      #print(t,len(p),"バス発車")
      bus +=1
  else:
    t=U[k]
    p=[]
    #print(t,len(p),"時間max,最終バス発車")
    bus +=1
    k =N
    
print(bus)

Submission status: Accepted

Solution code:
def main():
    n, c, k, *t = map(int, open(0).read().split())
    t.sort()
    u = tuple(t)

    cnt = 1
    p, l = 0, u[0] + k
    for v in t:
        if v <= l and p < c:
            p += 1
        else:
            cnt += 1
            p = 1
            l = v + k
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n, c, k, *t = map(int, open(0).read().split())
    t = sorted(t)
    u = tuple(t)

    cnt = 1
    p, l = 0, u[0] + k
    for v in t:
        if v <= l and p < c:
            p += 1
        else:
            cnt += 1
            l = v + k
            p = 1
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

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

cnt = 1
teiin = 1
for i in range(n):
    if i == 0:
        mati = t[i] + k
    else:
        if teiin < c:
            if mati >= t[i]:
                teiin += 1
            else:
                cnt += 1
                teiin = 1
                mati = t[i] + k
        else:
            cnt += 1
            teiin = 1
            mati = t[i] + k


print(cnt)

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()
x = 0
ans = 1
w = T[0] + k
for i in range(n):
    if T[i] <= w and x < c:
        x += 1
    else:
        ans += 1
        x = 1
        w = T[i]+k
print(ans)

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 = sorted(T)
ans = 0
waiting = []
for t in T:
  if len(waiting) == C:
    ans += 1
    waiting = []
  if len(waiting) > 0 and t > waiting[0] + K:
    ans += 1
    waiting = []
  waiting.append(t)
else:
  ans += 1
print(ans)

Submission status: Accepted

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

ans = 0
cnt = 1
flg = 0
prev = Ts[0]
for i in range(1,len(Ts)):
    now = Ts[i]
    if now - prev <= k:
        cnt += 1
    else:
        ans += 1
        cnt = 1
        prev = Ts[i]
    if cnt > c:
        ans += 1
        cnt = 1
        prev = Ts[i]
    # print("i",i,"cnt",cnt,"ans",ans)
print(ans)

Submission status: Accepted

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

# print(N, C, K)
# print(*T, end="\n")

# 現在の時刻
# 前から詰めていく (容量制約を忘れない)
count = 0
i = 0
while i < N:
    timax = T[i] + K
    # 乗せた人数
    c = 0
    count += 1
    while i < N and c < C and T[i] <= timax:
        c += 1
        i += 1
print(count)

Submission status: Accepted

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

t.sort()

diff = 0
cnt = 1
ans = 0
for i in range(n - 1):
    diff += abs(t[i + 1] - t[i])
    cnt += 1
    if diff > k or cnt > c:
        cnt = 1
        diff = 0
        ans += 1
print(ans + 1)

Submission status: Accepted

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

for t in T:
    if t>base+K or count>=C:
        answer+=1
        base=t
        count=1
    else:
        count+=1
    #print(t,count)
answer+=1

print(answer)

Submission status: Accepted

Solution code:
from math import ceil


def main():
    passengers, capacity, waiting_limit = map(int, input().split())
    arrive_time = [int(input()) for _ in range(passengers)]
    arrive_time.sort()
    count = 0
    waiting = 0
    waiting_since = -1
    for t in arrive_time:
        if waiting_since > 0 and waiting_since + waiting_limit < t or capacity <= waiting:
            count += ceil(waiting / capacity)
            waiting = 0
            waiting_since = -1
        waiting += 1
        if waiting_since < 0:
            waiting_since = t
    count += ceil(waiting / capacity)
    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
# input = sys.stdin.r/eadline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    N,C,K = MAP()
    T = [INT() for _ in range(N)]
    T.sort()
    passengers = 1
    deadline = T[0]+K
    answer = 0

    for i in range(1,N):
        if passengers<C and T[i]<=deadline:
            passengers += 1
        elif passengers == C or T[i]>deadline: #出発させる
            passengers = 1
            answer += 1
            deadline = T[i]+K
    if passengers>0:
        answer += 1
    print(answer)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
T = [int(input()) for _ in range(n)]
T.sort()
cnt = 0
ans = 1
t = T[0]
for i in range(n):
    cnt += 1
    if cnt > c or T[i] > t + k:
        ans += 1
        cnt = 1
        t = T[i]
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
bus = 1
air = T[0]
for i in range(N):
  cnt += 1
  if cnt == C + 1 or T[i] - air > K:
    bus += 1
    cnt = 1
    air = T[i]
  
print(bus)

Submission status: Accepted

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

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

ans = 1
time = -1
for i,t in enumerate(T):
    if time < 0:
        cnt, time = 1, t + K
    elif t <= time:
        cnt += 1
    else:
        ans += 1
        cnt, time = 1, t + K
    
    if cnt == C:
        time = -1
        ans += 1

print(ans)

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
tmp = 0
jousha = 0
for t in T:
    jousha += 1
    if jousha == 1:
        tmp = t

    if t - tmp > K:
        cnt += 1
        jousha = 1
        tmp = t
        continue

    if jousha == C:
        tmp = 0
        cnt += 1
        jousha = 0
        continue
if tmp != 0:
    cnt+=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, C, K = map(int,input().split())
T = sorted([int(input()) for _ in range(N)])
ans, cnt = 0, 0
st = T[0]
for i in range(N):
  if T[i] > st + K or cnt == C:
    ans += 1
    cnt = 1
    st = T[i]
  else:
    cnt += 1
print(ans+1)

Submission status: Accepted

Solution code:
N,C,K=map(int,input().split())
T=[int(input()) for _ in range(N)]
T.sort()
t=T[0]
cnt=0
mem=0
for i in range(N):
    if (t+K<T[i])or(mem==C):
        cnt=cnt+1
        t=T[i]
        mem=1
    else:
        mem=mem+1
print(cnt+1)

Submission status: Accepted

Solution code:
import bisect
import math
n, c, k = list(map(int, input().split()))
t = [0] * n
for i in range(n):
    t[i] = int(input())
t.sort()
bus_count = 0
pre_index = 0
index = 0
while index < n:
    #indexを乗せるバスが発車する時間
    leave = t[index] + k
    count = 0
    bus_count += 1
    while index < n and count < c and leave >= t[index]:
        count += 1
        index += 1
print(bus_count)

Submission status: Accepted

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

j = 0
count = 1
while j + count in range(n):
  if a[j + count] <= a[j] + k and count < c:
    count = count + 1
  else:
    bus = bus + 1
    j = j + count
    count = 1
print(bus)

Submission status: Accepted

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

T.sort()

bus = 0  # 出発したバスの台数
wait = 0  # 待っている人
dep = None  # 次のバスの出発時刻

for ti in T:
    if dep is None:  # バスを準備
        dep = ti + K
        bus += 1
    elif ti > dep:  # 前のバスの発車時間を過ぎている
        dep = ti + K
        bus += 1
        wait = 0

    wait += 1

    if wait == C:  # 満員になった
        dep = None
        wait = 0

print(bus)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, C, K = (int(i) for i in input().split())
    T = [int(input()) for i in range(N)]
    T.sort()
    from collections import deque
    que = deque([])
    ans = 0
    for t in T:
        if que and que[0] < t:
            for _ in range(C):
                if que:
                    que.popleft()
                else:
                    break
            ans += 1
        que.append(t+K)
        if len(que) >= C:
            for _ in range(C):
                if que:
                    que.popleft()
                else:
                    break
            ans += 1
    if que:
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n, c, k = map(int, input().split())
    t = [None]*n
    for i in range(n):
        t[i] = int(input())
    t.sort()
    ans = 0
    l = 0
    x = t[0]+k
    for r in range(1, n):
        if x < t[r] or c < r-l+1:
            ans += 1
            l = r
            x = t[r] + k
        if r == n-1:
            ans += 1
    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)]+[10**10]
t.sort()
b=1
p=0
if c==1:
  print(n)
  exit()
while p<n:
  l=t[p]+k
  pp=1
  f=1
  while pp<c and f:
    p+=1
    if t[p]<=l:
      pp+=1
      if pp==c:
        p+=1
    else:
      f=0
  if p<n:
    b+=1
print(b)

Submission status: Accepted

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

min_t = 0
i = 0
while i < N:
    ans += 1
    start = i
    while i < N and T[i] - T[start] <= K and i - start < C:
        i += 1
print(ans)

Submission status: Accepted

Solution code:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

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

fst = T[0]
cnt = 0
ans = 0
flg = 0

for i in range(N):
    cnt += 1
    flg = 0
    if T[i]-fst > K:
        fst = T[i]
        cnt = 1
        ans += 1
    
    elif cnt == C:
        fst = T[i+1]
        cnt = 0
        ans += 1
        flg = 1


    # print(i,T[i],flg,fst,ans,cnt)

if not(flg):
    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()
key = t[0]+k
len_t = 0
ans1 = 0
for i in range(n):
    if t[i] <= key and len_t < c:
        len_t += 1
    else:
        ans1 += 1
        key = t[i]+k
        len_t = 1
ans1 += 1
print(ans1)

Submission status: Accepted

Solution code:
n, c, k = [int(e) for e in input().split()]# 5 3 5
t = [] # 1 2 3 6 12
bus_count = 0
time_diff = 0
stock = 0
first_customer_arrival_time = 0
i = 0

for _ in range(n):
    t.append(int(input()))
t.sort()
while i < n-1:
    # First customer
    if stock == 0:
        first_customer_arrival_time = t[i]
        stock = 1
    else:
        stock += 1
    time_diff = t[i+1] - first_customer_arrival_time
    # Timeout or Full
    if time_diff > k or stock == c:
        bus_count += 1
        stock = 0
        time_diff = 0 
    i += 1
# Lastbus
bus_count += 1
print(bus_count)

Submission status: Accepted

Solution code:
N,C,K = list(map(int,input().split()))
T = [0]*N
for i in range(N):
  T[i] = int(input())
T.sort()
i = 0
ret = 0
while i < N:
  j = i
  ret += 1
  while j < N and j < i+C and T[j] <= T[i]+K:
    j += 1
  i = j
print(ret)