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, *t = map(int, open(0).read().split())
t.sort()
tmp = 0
cnt = 0
limit = t[0] + k
for time in t:
    if tmp == c or time > limit:
        limit = time + k
        tmp = 1
        cnt += 1
    else:
        tmp += 1
print(cnt + 1)

Submission status: Accepted

Solution code:
n,c,k = map(int ,input().split(" "))
t = sorted([int(input()) for i in range(n)])
total = 0
count = 0
while(count != n):
  temp = 0
  #print(count, total)
  for i in range(c):
    if count + i >= n:
      #print("乗りたい人数を全部さばいた")
      if t[-1] - t[count] <= k:
        #print("最後の人全員載せる")
        count = n
        total += 1
        break
      else:
        temp = 0
        while(count != n):
          #print("残りを何回で載せられるか")
          if t[count + temp] - t[count] <= k:
            temp += 1
          else:
            count += temp + 1
            total += 1
        break
      break
    if t[count + i] - t[count] > k:
      #print("定員を超えた")
      count += i
      total += 1
      break
  else:
    #print("k人全員載せる")
    count += c
    total += 1
    if count == n:
      break
print(total)

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)

las=T[0]+K
ans,cnt=0,0

for t in T:
    if cnt<C and las>=t:
        cnt+=1
    else:
        ans+=1
        cnt=1
        las=t+K

if cnt>0:
    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
vis = [False for i in range(n)]
for i in range(n):
  if vis[i]:
    continue
  vis[i] = True
  x = i
  lim = t[i]+k
  cnt = 1
  bus += 1
  while x < n and cnt <= c:
    if t[x] > lim:
      break
    i = x
    vis[x] = True
    x += 1
    cnt += 1
print (bus)

Submission status: Accepted

Solution code:
n,c,k = map(int,input().split())
t = sorted([int(input()) for _ in range(n)])
ans,ppl = 1,1
temp = t[0]
for v in t[1:]:
  if v-temp>k or ppl>=c:
    ans += 1
    ppl = 1
    temp = v
  else:
    ppl += 1
  #print(ans)
print(ans)

Submission status: Accepted

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

def check(T, i, j):
    tmp=[]
    for t in range(i,j):
        tmp.append(T[t])
    print(tmp)

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

T = sorted(tmp)

ans = i = 0
while i < N:
    start = T[i]
    num = 0
    for j in range(i+1, N):
        num += 1
        if T[j] - start > K or num == C:
            #check(T, i, j)
            i = j
            ans += 1
            break
    else:
        ans += 1
        break

print(ans)

Submission status: Accepted

Solution code:
N,C,K=map(int,input().split())
time=[]
for _ in range(N):
    T=int(input())
    time.append(T)
sort_time=sorted(time)
ans=1
max_N=0
max_time=sort_time[0]+K
for time in sort_time:
    if max_time==0:
        max_time=time+K
    if time<=max_time:
            max_N+=1
    else:
        ans+=1
        max_time=time+K
        max_N=1
        continue
    if max_N==C:
        ans+=1
        max_time=0
        max_N=0
if C==1:
    print(N)
else:
    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=0; now=0; nowc=0
for  ii in range(n):
    if now>=T[ii] and nowc<c: nowc+=1; continue
    now=T[ii]+k
    nowc=1
    ans+=1
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.sort()
s=0
lt=0
ln=0

if c==1:
    print(n)
    exit()
for i in range(n):

    if i==0:
       lt=i
       ln+=1

    else:
        if t[i]-t[lt]>k:
            s+=1
            lt=i
            ln=0

        ln+=1
        if ln==c:
            s+=1
            lt=i+1
            ln=0

        #print(i, s, lt, ln)


    
if ln>0:
    s+=1

print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()
busCount = 0
pCount = 0
time = 0
firstTime = 0
for i in range(N):
    time = T[i]
    if firstTime == 0:
        firstTime = T[i]
        busCount += 1
    pCount += 1
    if time > firstTime + K:
        firstTime = T[i]
        busCount += 1
        pCount = 1
        continue
    if pCount == C:
        firstTime = 0
        pCount = 0
print(busCount)

Submission status: Accepted

Solution code:
n,C,T=map(int,input().split())
t=[int(input()) for i in range(n)]
t.sort()
res=t[0]+T
cnt=1
ans=0
for i in range(1,n):
  if t[i]<=res and cnt<C:
    cnt+=1
  elif t[i]>res or cnt==C:
    ans+=1
    res=t[i]+T
    cnt=1
print(ans+1)

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

N,C,K = mint()
T = [int(input()) for _ in range(N)]
T.sort()
t0 = 0
i = 0
ans = 0
for t in T:
    if i==0:
        t0 = t
        i = 1
        ans += 1
    elif t-t0>K:
        t0 = t
        i = 1
        ans += 1
    else:
        i += 1
    if i==C:
        i = 0
print(ans)

Submission status: Accepted

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

a = 1; t = T[0] + K; c = 1
for i in range(1,N):
    if T[i]>t or c+1>C:
        a += 1; t = T[i] + K; c = 1
    else:
        c += 1
print(a)

Submission status: Accepted

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

T.sort()

ans = 0

cnt = 0
last = T[0] + K

for t in T:
    if cnt < C and last >= t:
        cnt += 1
    else:
        ans += 1
        cnt = 1
        last = t + K

if cnt > 0:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
n,c,k=map(int, input().split())
t=[]
for _ in range(n):
  tmp=[int(input())]
  t.extend(tmp)
t.sort()
t.append(10**10)
ans=0
cnt_pssngr=1
fst_pssnger_t=t[0]
for i in range(1,n+1):
  if cnt_pssngr<c and t[i]<=fst_pssnger_t+k:
    cnt_pssngr+=1
  else:
    ans+=1
    cnt_pssngr=1
    fst_pssnger_t=t[i]
print(ans)

Submission status: Accepted

Solution code:
from collections import deque
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
D = deque(sorted(T))
cnt = 1
ans = 1
pre = D.popleft()
flag = False
while D:
    d = D.popleft()
    cnt += 1
    if cnt > C or d - pre > K:
        cnt = 1
        pre = d
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
#54 A - Airport Bus
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T = sorted(T,reverse = False)
# 最後の一人をカウントするための番兵
T.append(10**10)

ans = 0
bus = 1
first = T[0]
for i in range(1,N+1):
    # T[i] がバスに乗ることができるとき
    if (bus < C) and (T[i] <= first + K):
        bus += 1
    # T[i] がバスに乗ることができないとき
    else:
        # 新しいバスの first になる
        ans += 1
        bus = 1
        first = T[i]
        
print(ans)

Submission status: Accepted

Solution code:
#54 A - Airport Bus
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T = sorted(T,reverse = False)

ans = 0
bus = 1
first = T[0]
for i in range(1,N):
    # T[i] がバスに乗ることができるとき
    if (bus < C) and (T[i] <= first + K):
        bus += 1
    # T[i] がバスに乗ることができないとき
    else:
        # 新しいバスの first になる
        ans += 1
        bus = 1
        first = T[i]
        
print(ans+1)

Submission status: Accepted

Solution code:
# vim: fileencoding=utf-8

import math


def main():
    n, c, k = map(int, input().split())
    t = []
    for x in range(n):
        t.append(int(input()))
    t.sort()
    ans = 0
    bucket = []
    for i in t:
        while len(bucket) >= c:
            ans += 1
            bucket = bucket[c:]
        while len(bucket) > 0 and bucket[0] + k < i:
            ans += 1
            bucket = bucket[c:]
        bucket.append(i)
    ans += math.ceil(len(bucket) / c)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

T.sort()

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

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

print(ans)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
data=[]
for i in range(n):
    data.append(int(input()))
data.sort()
i=0
count=0
while i <= n-1:
    j=i
    bus_join=0
    while bus_join < c and j <= n-1 and data[j]-data[i] <= k:
        j += 1
        bus_join += 1
    i=j
    count += 1
print(count)

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

Submission status: Accepted

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

flag = 0
cnt = 0
ans = 0
for i in range(len(T)):
    time = T[i] - T[flag]
    cnt += 1
    if time > K or cnt > C:
        flag = i
        cnt = 1
        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.sort()
cnt = 0
ans = 0
end = -1
for i,t in enumerate(t):
  if end < t:
    cnt = 1
    ans +=1
    end = t+k
  else:
    cnt +=1
  if cnt > c:
    cnt = 1
    ans +=1
    end = t+k
#  print("i",i,"t",t,"cnt",cnt,"ans",ans,"end",end)
print(ans)

Submission status: Accepted

Solution code:
def main():
    examA()

def examA():
    N, C, K = LI()
    T = [I()for _ in range(N)]
    T.sort()
    cnt = 1
    customer = 1
    start = T[0]
    for i in range(1,N):
        t = T[i]
        if start+K<t:
            cnt += 1
            customer = 1
            start = t
        else:
            if customer==C:
                customer = 1
                start = t
                cnt += 1
            else:
                customer += 1
    ans = cnt
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,alphabet_convert,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 1<<31
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    main()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Accepted

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

car = 0
passenger = 0
target_t, limit = 0, 0
for i, t in enumerate(t_sorted):
    if target_t == 0:
        target_t = t
        limit = t + K
    passenger += 1
    if passenger == C:
        car += 1
        passenger = 0
        target_t = 0
        continue
    if i != N - 1:
        if t_sorted[i + 1] > limit:
            car += 1
            passenger = 0
            target_t = 0
            continue
if passenger > 0:
    car += 1

print(car)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n,c,k  = map(int, input().split())
ts = [int(input()) for i in range(n)]
ts.sort()
cnt = 0
ans = 0
end = -1
for i, t in enumerate(ts):
    if end < t:
        cnt = 1
        ans += 1
        end = t + k
    else: # t <= end
        cnt += 1
    if cnt > c:
        cnt = 1
        ans += 1
        end = t + k
print(ans)

Submission status: Accepted

Solution code:
n,c,k = map(int,input().split())
ls = [int(input()) for _ in range(n)]
ls.sort()
ans = 0
cnt = 0
l,r = 0,0
for i in range(n):
    if l == 0:
        l = ls[i]
        r = ls[i] + k
    cnt += 1
    if cnt == c:
        ans += 1
        cnt = 0
        l = 0
        continue
    if i != n-1:
        if ls[i+1] > r:
            ans += 1
            cnt = 0
            l = 0
            continue
if cnt > 0:
    ans += 1
print(ans)

Submission status: Accepted

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

    busmintime = 0
    busmaxtime = K
    ans = 0
    cnt = 0
    i = 0
    for _ in range(N**2):
        busmintime = T[i]
        cnt += 1
        busmaxtime = busmintime + K
        for j in range(i+1, N):
            jtime = T[j]
            if jtime > busmaxtime or cnt == C:
                ans += 1
                cnt = 0
                i = j
                break
            cnt += 1
        if j == N-1:
            ans += 1
            break

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:


def Schedule(schedule):
    """
    :return: 複数の区間が与えられた時の重複の無い区間の選び方の最大数
    """
    schedule = sorted(schedule, key=lambda x: x[1])
    N = len(schedule)
    res = 0
    end = -float("inf")
    tmp = 0
    for i in range(N):
        if end < schedule[i][0] or tmp == C-1:  # 重複がダメならば等号を消す
            end = schedule[i][1]  # 終点でソートされているので、自動的に可能な中で最速の終点が選ばれている
            res += 1
            tmp = 0
        else:
            tmp += 1
    return res

################################################################################

import sys
input = sys.stdin.readline

N, C, K = map(int, input().split())
schedule = []
for i in range(N):
    start = int(input())
    schedule.append((start, start + K))               # schedule = (始点、終点)

print(Schedule(schedule))

Submission status: Accepted

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

T = sorted(int(input()) for _ in range(N))


i = 0
bus = 0
while i < N:
    bus += 1
    c = 0
    limit = T[i]+K
    while c < C and i < N and T[i] <= limit:
        c += 1
        i += 1

print(bus)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
t = list()
for i in range(n):
    t.append(int(input()))
t.sort()
flag = 0
cnt = 0
state = 0
for i in range(0,n):
    if flag != 0:
        flag = flag - 1
        state = 0
    else:
        for j in range(0,min(c,n-i)):
            if t[i+j]-t[i] <= k and j == min(c-1,n-i-1): 
                cnt = cnt + 1
                flag = min(c-1,n-i-1)        
                state = 1
                break
            elif t[i+j]-t[i] <= k:
                state = 2
            elif t[i+j]-t[i] > k:
                cnt = cnt + 1
                flag = j-1
                state = 3
                break
print(cnt)

Submission status: Accepted

Solution code:
N,C,K=map(int,input().split())
arrive=[]
c=0
for i in range(N):
    temp=int(input())
    arrive.append(temp)

arrive.sort()
sw=False
ans=0

for j in range(N):
    if sw==False:
        lim=arrive[j]+K
        c+=1
        sw=True
    else:
        c+=1
    if j<N-1:
        if c==C or lim<arrive[j+1]:
            ans+=1
            c=0
            sw=False
    else:
        ans+=1
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)

Standard = T[0] + K
count = 1


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

print(ans+1)

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,c,k = LI()
    ans = 0
    cnt = 0
    period = -1
    dps = [None for _ in range(n)]
    for i in range(n):
        dps[i] = I()
    dps.sort()
    
    for dp in dps:        
        if cnt == c or dp > period:
            ans += 1
            cnt = 1
            period = dp+k
        else:
            cnt += 1

    print(ans)
main()

Submission status: Accepted

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

ans = 0
cnt = 0
tmp_t = 0
for t in arr:
    if cnt == 0:
        tmp_t = t
    cnt += 1
    if t - tmp_t > k:
        ans += 1
        cnt = 1
        tmp_t = t
    elif cnt == c:
        ans += 1
        cnt = 0
if cnt:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
a = [int(s) for s in input().split()]
N = a[0]
si = a[1]
ti = a[2]
s = [int(input()) for i in range(N)]
s = sorted(s)
X = int(0)
ans = int(0)

#全員乗るまで繰り返す
while N != X:
    #まずバスを用意して先頭を乗せる
    X += 1 
    ans += 1
    #この時点で全員乗ったら終わりにする
    if N == X:
        break
    #バスの残りsi-1枠に乗れるだけ乗せる
    #そもそも乗客がsi-1人もいない場合は残りのN-X人が上限
    temp = X
    for i in range(min([si-1,N-X])):
        if s[temp + i] <= s[temp-1] + ti:
            X += 1
        else:
            break

print(ans)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
t = []
for _ in range(n):
    t.append(int(input()))
ans = 0
time_cnt = 0
mem_cnt = 1
t.sort()
for i in range(n - 1):
    time_cnt += t[i + 1] - t[i]
    mem_cnt += 1
    # print(time_cnt)
    if time_cnt > k or mem_cnt > c:
        time_cnt = 0
        mem_cnt = 1
        ans += 1
if mem_cnt == 0:
    ans += 1
elif mem_cnt > 0:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
t = []
for _ in range(n):
    t.append(int(input()))
t.sort()
passenger = 0
bus_flag = False
bus_launch = 0
ans = 0
for i in range(n):
    if not bus_flag:
        bus_launch = t[i] + k
        bus_flag = True

    if t[i] <= bus_launch:
        passenger += 1
        if passenger == c:
            ans += 1
            bus_flag = False
            passenger = 0
    else:
        ans += 1
        bus_launch = t[i] + k
        passenger = 1

if passenger != 0:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n ,c, k = inintm()

T = []
ans = 1

for _ in range(n):
    T.append(inint())

T.sort()

f = T[0]
cnt = 1

for i in range(1,n):
    cnt += 1
    if T[i] - f <= k and cnt <= c:
        continue
    else:
        f = T[i]
        ans += 1
        cnt = 1

print(ans)

Submission status: Accepted

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

limit = T[0] + k
bus = [0]
ans = 0
for t in T:
    if t <= limit:
        if bus[-1] < c:
            bus[-1] += 1
        else:
            bus.append(1)
            limit = t + k

    else:
        limit = t + k
        ans += len(bus)
        bus = [1]

ans += len(bus)

print(ans)

Submission status: Accepted

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

counter = 1
start = -1
wating_num = 0
for t in T:
  if start < 0:
    start = t
  if t - start > k or wating_num + 1 > c:
    counter += 1
    wating_num = 0
    start = t
  wating_num += 1
print(counter)

Submission status: Accepted

Solution code:
# https://kenkoooo.com/atcoder/#/contest/show/60231d3e-b3c8-4d84-87b4-3d3739b98e19

n, c, k = [int(i) for i in input().split()]

passengers = []

for _ in range(n):
    passengers.append(int(input()))

passengers = sorted(passengers)

bus = 0
cnt = 0
ptr = 0
first = None

for t in passengers:
    if cnt == 0:
        cnt = 1
        first = t
    elif cnt == c:
        cnt = 1
        first = t
        bus += 1
    elif cnt < c and t - first <= k:
        cnt += 1
    elif cnt < c and t - first > k:
        bus += 1
        first = t
        cnt = 1
else:
    if cnt > 0:
        bus += 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 = sorted(t)
bus = []
ans = 1
for i in range(n):
    if len(bus) < c: #バスの定員に余裕があるとき
        if not bus:#バスに誰も乗っていなかったらバスに人を乗せる
            bus.append(t[i])
        elif t[i] <= bus[0] + k:#バスに初めて人が乗った時刻にkを足して、それよりt[i]が小さければバスに乗せる
            bus.append(t[i])
        else:#上記のelifを満たさない場合
            ans +=1
            bus = []
            bus.append(t[i])
    elif len(bus) == c:
        ans +=1
        bus = []
        bus.append(t[i])
    else:
        ans +=1
        bus = []
print(ans)

Submission status: Accepted

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

S = []
for i in range(N):
    S.append(T[i] + K)
ans = 0
bus = 0
count = 0
for i in range(N):
    if T[i] <= bus and count < C:
        count += 1
    else:
        bus = S[i]
        count = 1
        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()
s = 0
ans = 0
for i in range(N):
    if i - s + 1 > C or T[i] - T[s] > K:
        s = i
        ans += 1
print(ans+1)

Submission status: Accepted

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

ans = 0
tmp = lis[0]
cnt = 0
for i in range(n):
    if tmp+k >= lis[i] and cnt <= c-1:
        cnt += 1
    else:
        ans += 1
        tmp = lis[i]
        cnt = 1

print(ans + 1)

Submission status: Accepted

Solution code:
def main():
    n, c, k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    t.sort()
    ans = 0
    passengers = 0
    first = t[0]
    for tn in t:
        if tn > first + k or passengers == c:
            ans += 1
            passengers = 0
            first = tn
        passengers += 1

    print(ans + 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
_, c, k, *t = map(int, open(0).read().split())
t.sort()
n = 0
f = t.pop(0)
p = 1
for i in t:
    if i > f + k or p >= c:
        n += 1
        p = 1
        f = i
    else:
        p += 1
print(n + 1)

Submission status: Accepted

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

# パラメタの初期化
now = 0
now_f = 1
p = 0
cnt = 0

for t in T:
    # nowの更新
    if now_f == 1:
        now_f = 0
        now = t

    if t <= now + K:
        p += 1
        if p == C:
            p = 0
            cnt += 1
            now_f = 1

    else:
        p = 1
        cnt += 1
        now = t
        now_f = 0


if p == 0:
    print(cnt)
else:
    print(cnt + 1)

Submission status: Accepted

Solution code:
from collections import deque
N, C, K = map(int, input().split())
times = []
for _ in range(N):
    time = int(input())
    times.append(time)
times.sort()
times = deque(times)
ans = 0
bus_time = times[0] + K
human = 0
while times:
    if times[0] <= bus_time:
        times.popleft()
        human += 1
        if human == C:
            ans += 1
            human = 0
            if times:
               bus_time = times[0] + K
    else:
        human = 0
        ans += 1
        bus_time = times[0] + K
if human:
    print(ans + 1)
else:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])
ans = 1
passenger = 0
limit = t[0] + k
 
for p in t:
    if passenger < c and p <= limit:
        passenger += 1
    else:
        ans += 1
        passenger = 1
        limit = p + k
print(ans)

Submission status: Accepted

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

for p in t:
    if passenger < c and p <= limit:
        passenger += 1
    else:
        ans += 1
        passenger = 1
        limit = p + k
print(ans)

Submission status: Accepted

Solution code:
#
# agc011 a
#

import sys
from io import StringIO
import unittest


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)


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

    ans = 0
    u = 0
    s = T[N-1] + K + 1
    for t in reversed(T):
        if t + K >= s and u < C:
            u += 1
        else:
            ans += 1
            s = t
            u = 1

    print(ans)


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

Submission status: Accepted

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

bus = []
departure=0

T.sort()

for passenger in T:
  if bus == []:
    bus.append(passenger)
    
  elif passenger <= bus[0]+K and len(bus)<=(C-1):
    bus.append(passenger)
  
  else:
    bus.clear()
    departure+=1
    bus.append(passenger)
    
if bus != []:
  print(departure + 1)
else:
  print(departure)

Submission status: Accepted

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

	num_bus = 1
	num_passenger = 1
	first_passenger = T[0]

	for i in range(1, N):
		if first_passenger + K < T[i]:
			first_passenger = T[i]
			num_passenger = 1
			num_bus += 1
		elif num_passenger == C:
			first_passenger = T[i]
			num_passenger = 1
			num_bus += 1
		else:
			num_passenger += 1

	print(num_bus)
		

 
if __name__ == "__main__":
  	main()

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())  # 人数N, バスの定員C, Ti以上Ti+K以下の時刻に出発するバスに乗らせる必要がある
T = [int(input()) for _ in range(N)]
# print(T)
T.sort()
ans = 1
bus_passengers = 1  # 最大Cまでいける
time_limit = T[0]+K
for i in range(1, N):
    # print(i, ans, time_limit)
    if time_limit >= T[i] and C > bus_passengers:
        bus_passengers += 1
    else:
        # 定員数的に乗りきらないもしくは，時間的に乗れない
        time_limit = T[i]+K
        bus_passengers = 1
        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 = 0
cnt = 0
tmp = 0
s = t[0]

while tmp < n:
    t1 = t[tmp]
    cnt += 1
    if t1 - s > k:
        ans += 1
        cnt = 1
        s = t[tmp]
    elif cnt == c:
        if tmp < n - 1:
            s = t[tmp + 1]
            ans += 1
            cnt = 0

    tmp += 1

if cnt > 0:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
def solve():

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

    T = sorted(T)
    i = 0
    k = 0

    ans = 0

    #print(T)

    while i < N:
        n = 0
        while k < N and n < C and T[i] <= T[k] <= T[i]+K:
            n += 1
            k += 1
            if n == C:
                ans += 1
                break

        if n != C:
            ans += 1

        i = k



    print(ans)            


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
N,C,K=map(int,input().split())
T=[int(input()) for _ in range(N)]
T.sort()
#print(T)
if C==1:
    print(N)
    exit()
ans=0
i=0
j=1
tmp=1
while True:
    #print(i,j)
    if j-i==C:
        if j==N:
            ans+=1
            break
        ans+=1
        i=j
        j=i+1
        tmp=1
    if j>=N:
        ans+=1
        break
    if i!=N-1:
        if T[j]-T[i]>K:
            ans+=1
            i=j
            j=i+1
            tmp=1
            continue
        else:
            j+=1
            tmp+=1
print(ans)