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 = list(map(int,input().split()))
T = [int(input()) for _ in range(N)]

T.sort()

cnt = 0
passengers = 0
due = 0
for t in T:
  if passengers == 0:
    cnt +=1
    passengers += 1
    due = t + K
  elif passengers > 0 and passengers < C and t <= due:
    passengers +=1
  elif t > due or passengers == C:
    passengers = 1
    due = t + K
    cnt +=1
  #print(t, passengers, due, cnt)

print(cnt)

Submission status: Accepted

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

time = 0
limit = st[0]+k

d = {}
d[limit] = []
ans = 1
for i, p in enumerate(st):
  if p <= limit and len(d[limit]) < c:
    d[limit].append(p)
  else:
    limit = p + k
    ans += 1
    d[limit] = [p]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, C, K, *T = map(int, open(0).read().split())
T.sort()
# print(N, C, K, T)

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

ans = 0
for i in range(N):
    t = T[i]
    if t == -1:
        continue
    remain = C - 1
    for j in range(i + 1, N):
        tj = T[j]
        if tj == -1:
            continue
        if tj > t + K:
            break
        remain -= 1
        T[j] = -1
        if remain == 0:
            break
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    input = stdin.readline

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

    T = [0] * N

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

    T.sort()

    bus_num = 1
    jyokyaku = 1
    bus_start = T[0]

    for i in range(1,N):
        jyokyaku = jyokyaku + 1
        # jyokyakuが乗れる人数を超えると新しいバスを用意
        if(C < jyokyaku):
            bus_num = bus_num + 1
            bus_start = T[i]
            jyokyaku = 1
        elif(T[i] - bus_start > K):
            bus_num = bus_num + 1
            bus_start = T[i]
            jyokyaku = 1

    
    print(bus_num)


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()

p = 0
w = t[0]
res = 0

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:
n, c, k = map(int, input().split())
dat = []
for _ in range(n):
    dat.append(int(input()))
dat.sort()
cn = 1
nt = dat[0] + k
res = 1
for i in range(1, n):
    #print("i", i, "res", res)
    # もう前のバスがいっぱい
    if cn == c:
        #print("full")
        cn = 1
        nt = dat[i] + k
        res += 1
        continue
    if dat[i] > nt:
        #print("gogogo")
        cn = 1
        nt = dat[i] + k
        res += 1
        continue
    cn += 1
print(res)

Submission status: Accepted

Solution code:
N,C,K=map(int,input().split())
T=[int(input()) for i in range(N)]
T.sort()
 
count=1
cus=0
pre=T[0]
for t in T:
    if C>cus and pre+K>=t:
        cus+=1
    else:
        cus=1
        pre=t
        count+=1
print(count)

Submission status: Accepted

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

cnt = 0
ans = 0
lst = [int(input()) for _ in range(N)]
lst = sorted(lst)
next_t = 10**10
for t in lst:
  next_t = min(t+K,next_t)
  if (t > next_t):
    ans += 1
    cnt = 0
    next_t = t+K
    
  cnt += 1
  if (cnt == C):
    ans += 1
    cnt = 0
    next_t = 10**10
    
if (cnt > 0):
  ans += 1
print(ans)

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()
a = c_ = idx = 0
t_ = t[0]
while idx < n:
    if t[idx] - t_ > k or c_ == c :
        a += 1
        t_ = t[idx]
        c_ = 0
    elif idx == n - 1:
        idx += 1
        a += 1
    else:
        idx += 1
        c_ += 1
print(a)

Submission status: Accepted

Solution code:
# AGC 011 A - Airport Bus
#time limitは一番待たされている客基準⇒sortの先頭
N,C,K = map(int,input().split())
T = [int(input()) for __ in range(N)]

ans = 1 #最低1台はバスが出る
count = 0 #乗客の数をカウント,最大C人まで
T.sort()
ts = T[0] #一番待たされている客の到着時間

#print(T)
for t in T:
    if t-ts > K or count == C: #時間いっぱい or 乗客がいっぱいになったら
        ans += 1 #バス追加
        ts = t #次の客の待ち時間
        count = 1 #乗客数リセット
    else:
        count += 1 #乗客+1
print(ans)

Submission status: Accepted

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

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

tss = sorted(ts, reverse=True)

base = tss[0]
count = 0
limit = 0
for i in range(n):
    limit += 1
    if base - tss[i] > k or limit > c:
        count += 1
        base = tss[i]
        limit = 1
count += 1
print(count)

Submission status: Accepted

Solution code:
N,C,K,*T=map(int, open(0).read().split())
T=sorted(T)
ans=0
cap=0
s=-1
for t in T:
    if t<=s and cap>0:
        cap-=1
    else:
        s=t+K
        cap=C-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()

bus = []

count = 0
for i in range(N):
    if count == 0:
        first = T[i]
        count += 1
    else:
        if T[i] - first <= K:
            count += 1
        else:
            bus.append(count)
            first = T[i]
            count = 1
    if count >= C:
        bus.append(count)
        count = 0

if count > 0:
    bus.append(count)

print(len(bus))

Submission status: Accepted

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

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

bus = []
indexes = [i for i in range(N)]
sorted_indexes = sorted(indexes, key=lambda i: T[i])

count = 0
for i in range(N):
    if count == 0:
        first = T[sorted_indexes[i]]
        count += 1
    else:
        if T[sorted_indexes[i]] - first <= K:
            count += 1
        else:
            bus.append(count)
            first = T[sorted_indexes[i]]
            count = 1
    if count >= C:
        bus.append(count)
        count = 0

if count > 0:
    bus.append(count)

print(len(bus))

Submission status: Accepted

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

pas = 1
last_bus = t[0] + k
ans = 1

for i in t[1:]:
  if i <= last_bus and pas < c:
    pas +=1
  else:
    ans +=1
    pas =1
    last_bus = i + k
    
    
print(ans)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
t=[int(input()) for i in range(n)]
t=sorted(t)
time=t[0]
cnt=0
ans=0
for i in range(n):
    #制限時間以内かつC人以内
    if time+k>=t[i] and cnt<=c-1:
        cnt+=1

    else:
        ans+=1
        time=t[i]
        cnt=1
print(ans+1)

Submission status: Accepted

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

users = sorted(users, reverse=False)

ans = 0
pos = 0
start = 0

while True:
    count = 0

    if pos == N:
        break
        
    start = users[pos]
#     print("start:{}".format(start))
    for i in range(C):
        if pos+i < N and users[pos+i] <= start+K:
            count += 1
        else:
            break
    pos += count
#     print("pos:{}".format(pos))
    ans += 1
#     print("ans:{}".format(ans))

print(ans)

Submission status: Accepted

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

def main():
    N, C, K = map(int, input().split())
    times = sorted([int(input()) for _ in range(N)])
    passengers = []
    ans = 0
    while True:
        if len(times) == 0:
            if len(passengers) > 0:
                ans += 1
            break
        elif len(passengers) == 0:
            passengers.append(times.pop(0))
        elif times[0] - passengers[0] <= K:
            passengers.append(times.pop(0))
        elif times[0] - passengers[0] > K:
            ans += 1
            passengers = []

        if len(passengers) == C:
            ans += 1
            passengers = []
    print(ans)

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()
bus_time = [T[0]+K]
bus_num = [0]
t = 0

for i in range(N) :
    if bus_num[t] <= C - 1 :
        if bus_time[t] >= T[i] :
            bus_num[t] += 1
        else :
            t += 1
            bus_time.append(T[i]+K)
            bus_num.append(1)
    else :
        t += 1
        bus_time.append(T[i]+K)
        bus_num.append(1)

print(len(bus_time))

Submission status: Accepted

Solution code:
def boundary_find(array, limit):
    ceil = len(array) - 1 
    floor = 0
    while 1:
        center = (ceil + floor) // 2
        if array[center] <= limit:
            floor = center
        else:
            ceil = center
        if ceil - floor == 1:
            break
    return ceil

n, c, k = map(int, input().split())
tList = [int(input()) for _ in range(n)]
tList.sort()
count = 0
first = 0
while 1:
    limit = tList[first] + k
    last = min(first + c, n)
    if tList[last - 1] <= limit:
        mark = last
    else:
        mark = boundary_find(tList, limit)
    count += 1
    first = mark
    if first == n:
        break
print(count)

Submission status: Accepted

Solution code:
from collections import deque

def main():
    N,C,K = map(int,input().split())
    T = deque(sorted([int(input()) for _ in range(N)]))
    ans = 0
    while len(T) != 0:
        tmp = T.popleft()
        limit = tmp + K
        count = 1
        while count < C and len(T) != 0:
            tmp = T.popleft()
            if tmp > limit:
                T.appendleft(tmp)
                break
            else:
                count += 1
        ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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


#----------
N,C,K = list(map(int, input().rstrip().split()))

T_list = [int(input().strip()) for _ in range(N)]
T_list.sort()

#----------
num_bus=0
i=0
while i < len(T_list):

    # Busに何人乗せられるか時刻を比較
    member_bus=0
    break_flg=False
    for j in range(C):
        if (i+j) < len(T_list):
            if T_list[i+j] <= (T_list[i] + K):
                member_bus += 1
            else:
                break_flg=True
        else:
            break_flg=True
        
        if break_flg:
            break

    num_bus += 1
    i = i + member_bus
            

print(num_bus)

Submission status: Accepted

Solution code:
from collections import deque

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

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

T = sorted(T)
con = 0
bus = deque()

for i in range(N):
  t = T[i]
  #バスに乗れるなら乗せる
  ##乗客が0人の時は問答無用で乗れる
  ##乗客がいる場合、最初の乗客が乗った時間から経過時間がK未満
  ##なおかつ、乗客がC人未満なら乗れる
  if len(bus) == 0 or (t - bus[0] <= K and len(bus) < C):
    bus.append(t)
  else:
    bus = deque()
    con += 1
    bus.append(t)
    
if len(bus) > 0:
  con += 1
  
print(con)

Submission status: Accepted

Solution code:
N,C,K=map(int,input().split(' '))
T=sorted([int(input()) for i in range(N)])
pas = 1
last_bus=T[0]+K
ans = 1
for i in T[1:]:
    if i <= last_bus and pas < C:
        pas += 1
    else:
        ans += 1
        pas = 1
        last_bus = i+K
print(ans)

Submission status: Accepted

Solution code:
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

from math import ceil

n, c, k = na()
T = nin(n)
T.sort()

ans = 0
i = 0
while i < n:
    m = T[i] + k
    cnt = 0
    while i < n and T[i] <= m and cnt < c:
        i += 1
        cnt += 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()

def solve(i):
    global N, C, K, T
    left = C - 1
    if i == N - 1:
        return i
    if left == 0:
        return i
    for j in range(i + 1, N):
        # print(T[i], i, j)
        if T[i] + K < T[j]:
            return j - 1
        else:
            left -= 1
        if left == 0 or j == N - 1:
            return j

buses = 0
start = -1
for i in range(N):
    if start < i:
        start = solve(i)
        buses += 1

print(buses)

Submission status: Accepted

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

bus = 1
st = T_lst[0]
num = 1
for i in range(1, N):
    if T_lst[i] <= st + K and num < C:
        num += 1
    else:
        bus += 1
        st = T_lst[i]
        num = 1
print(bus)

Submission status: Accepted

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

t=[]
for i in range(n):
 start_t=int(input())
 t.append([start_t,start_t+k])
t=sorted(t,key=lambda x:x[1])

ans=0
inx=0
while inx<n:
 ans+=1
 time=t[inx][1]

 for i in range(c):
  if inx==n:
   break
  if time>=t[inx][0]:
   inx+=1
  else:
   break

print(ans)

Submission status: Accepted

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

ans = 1
bus = C
time = T[0] + K
for i in T:
    # バスの定員に空きがあり、かつ、乗車1人目の許容時間内の場合同じバスに乗る
    if (bus > 0) & (i <= time):
        bus -= 1
    # バスが定員、または、乗車1人目の許容時間外の場合新しいバスに乗る
    else:
        bus = C - 1
        time = i + 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()

ans = 1
bus = T[0]
l = 1
for i in range(1,N):
    if T[i]-bus <= K and l <= C-1:
        l += 1
    else:
        bus = T[i]
        l = 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()

ans = 1
bus = [T[0]]
l = 1
for i in range(1,N):
    if T[i]-bus[0] <= K and l <= C-1:
        l += 1
    else:
        bus = [T[i]]
        l = 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()

ans = 1
bus = [T[0]]
for i in range(1,N):
    if T[i]-bus[0] <= K and len(bus) <= C-1:
        bus.append(T[i])
    else:
        bus = [T[i]]
        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()

ans = 0
bus = [T[0]]
for i in range(1,N):
    if T[i]-bus[0] <= K and len(bus) <= C-1:
        bus.append(T[i])
    else:
        bus = [T[i]]
        ans += 1
if bus != []:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,c,k=mii()
arr=lin(n)
arr.sort()

bas_cnt=1
pep_cnt=0
time=arr[0]+k

for i in range(n):
    #時間の判別or更新
    arri=arr[i]
    if arri <= time:
        if pep_cnt < c:
            pep_cnt+=1
        else:
            bas_cnt+=1
            pep_cnt=1
            time=arri+k
            
    else:
        bas_cnt+=1
        pep_cnt=1
        time=arri+k
    #print(bas_cnt,pep_cnt,time)
print(bas_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
ans = 1
time = T[0]
for i in range(N-1):
    cnt += 1
    if cnt == C or time + K < T[i+1]:
        ans += 1
        cnt = 0
        time = T[i + 1]

print(ans)

Submission status: Accepted

Solution code:
N,C,K = map(int,input().split())
T = sorted([int(input()) for i in range(N)],reverse=1)
count = 0
bus = 0
arr = T[0] -K
for i in range(N):
    if arr <= T[i]:
        count += 1
    else:
        count = 1
        arr = T[i] - K
        bus += 1

    if count == C:
        bus += 1
        count = 0
        if i != N-1:
            arr = T[i+1]-K 
if count:
    bus += 1
print(bus)

Submission status: Accepted

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

start,ans,cnt=T[0],0,0
for i in range(n+1):
    if start+k<T[i] or cnt+1>c:
        ans +=1
        cnt=0
        start=T[i]
    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
count = 0

for i in range(N):
    now = Tlist[i]
    if count == 0:
        rl = now + K
        count += 1
        continue
    else:
        if now <= rl <= now + K and count < C:
            count += 1
        else:
            ans += 1
            rl = now + K
            count = 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()

now = 0
past = t[0]
num = 0
ans = 1

for i in range(n):
    now = t[i]
    num += 1

    if now-past > k or num > c:
        ans += 1
        num = 1
        past = t[i]

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N, C, K = Scanner.map_int()
    T = Scanner.int_cols_list(N)
    T.sort()
    ans = 0
    cnt = 0
    lim = 0
    for i in range(N):
        if cnt == 0:
            lim = T[i] + K
        elif lim < T[i]:
            ans += 1
            lim = T[i] + K
            cnt = 0
        cnt += 1
        if cnt == C:
            ans += 1
            cnt = 0
            lim = 0
    if cnt > 0:
        ans += 1
    print(ans)
    return


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()

# print(T)

bus = 1
org = T[0]
_count = 0

for t in T:

    if t - org <= K and _count < C:
        _count += 1
        # print('1- t:{}, org:{}, _count:{}, bus:{}'.format(t, org, _count, bus))
    else:
        bus += 1
        org = t
        _count = 1
        # print('2- t:{}, org:{}, _count:{}, bus:{}'.format(t, org, _count, bus))

print(bus)

Submission status: Accepted

Solution code:
N, C, K = map(int,input().split())
T = [int(input()) for i in range(N)]
# print(T)
T.sort()
# print(T)
time = T[0]
people = 0
bus = 1
for i in T:
    people += 1 #乗客を乗せようとする
    if i - time > K or people > C: #乗せられないとき
        bus += 1 
        time = i
        people = 1 #次のバスに客iを乗せる
print(bus)

Submission status: Accepted

Solution code:
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()
time = li[0]
people = 0
bus_num = 1

for i in li:
    people += 1
    if i-time > k or people > c:
        bus_num += 1
        time = i
        people = 1
print(bus_num)

Submission status: Accepted

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

passengers = sorted([int(input()) for i in range(N)])
res = 0
bus_time = passengers[0]
bus_count = C
for p in passengers:
    if bus_count == 0 or p - bus_time > K:
        res += 1
        bus_time = p
        bus_count = C - 1
    else:
        bus_count -= 1
if bus_count != C:
    res += 1
print(res)

Submission status: Accepted

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

bus_t = -k - 100
bus_c = c
ans = 0

for t in T:
    bl = (bus_t + k >= t) and (bus_c + 1 <= c)
    if bl:
        bus_c += 1
        continue
    ans += 1
    bus_t = t
    bus_c = 1
print(ans)

Submission status: Accepted

Solution code:
N,C,K = map(int,input().split())
T = []
for _ in range(N):
    t = int(input())
    T.append(t)
T.sort()
t_0 = T[0]
ans = 0
c = C
for t in T:
    if c == 0 or t - t_0 > K:
        ans += 1
        t_0 = t
        c = C - 1
    else:
        c -= 1
if c != C:
    ans += 1
print(ans)

Submission status: Accepted

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

T.sort(key = lambda x: x[1])
c = 0
bus = 0
limit = T[0][1]

for i, t in enumerate(T):
  if limit < t[0]:  # バスが出発していなければならない
    c = 1
    bus += 1
    limit = t[1]
  elif (c+1) > C:  # 自分が乗れずに出発して自分は次のバスに乗る
    c = 1
    bus += 1
    limit = t[1]
  else:  # いたバスで待つ
    c += 1

if c > 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()

res = 0

t_0 = T[0]
c = C

for t in T:
    if c == 0 or t - t_0 > K:
        res += 1
        t_0 = t
        c = C - 1
    else:
        c -= 1
else:
    if c != C:
        res += 1

print(res)

Submission status: Accepted

Solution code:
import sys

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

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

cnt = 0
capacity = 0
time_limit = 0
for i in range(N):
	if capacity == 0:
		capacity += 1
		time_limit = T[i] + K
		continue
	if capacity > 0:
		if T[i] <= time_limit:
			capacity += 1
			if capacity == C:
				cnt += 1
				capacity = 0
				continue
		elif T[i] > time_limit:
			cnt += 1
			capacity = 1
			time_limit = T[i] + K


print(cnt+1)

Submission status: Accepted

Solution code:
import sys
n, c, k = [int(i) for i in sys.stdin.readline().split()]
t_ls = []
for i in range(n):
    t = int(sys.stdin.readline().strip())
    t_ls.append(t)
t_ls.sort()
last = t_ls[0]
cnt = 1
ans = 1
for t in t_ls[1:]:
    if t <= last + k and cnt < c:
        cnt += 1
        continue
    last = t
    cnt = 1
    ans += 1
print(ans)

Submission status: Accepted

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

count = 0
ans = 0

newLi = sorted(li)

while(len(newLi)):
  for c in range(C - 1):
    if len(newLi) < 2:
      break
    
    if newLi[1] <= newLi[0] + K:
      newLi.pop(1)
    else:
      break

  newLi.pop(0)
  ans += 1

print(ans)

Submission status: Accepted

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

listT.sort()

count=0
while listT != []:
    bus = []
    time = listT[0]
    count += 1
    while len(bus) != C and time+K>=listT[0]:
        bus.append(listT.pop(0))
        if listT==[]:
            break

print(count)

Submission status: Accepted

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

listT.sort(reverse = True)

count=0
while listT != []:
    bus =[]
    time = listT[0]
    count += 1
    while len(bus) != C and time - K <= listT[0]:
        bus.append(listT.pop(0))
        if listT ==[]:
            break

print(count)

Submission status: Accepted

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

count=1
cus=0
pre=T[0]
for t in T:
    if C>cus and pre+K>=t:
        cus+=1
    else:
        cus=1
        pre=t
        count+=1
print(count)

Submission status: Accepted

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

out = T.pop(0) + k
peo = 1
bus = 1

for t in T:
    if t <= out and peo < c:
        peo += 1

    else:
        out = t + k
        peo = 1
        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()
time = T.pop(0)
people = 1
ans = 1
for t in T:
    if t <= time + K and people < C:
        people += 1
    else:
        time = t
        people = 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)])
s, c = 0, 0
ans = 0
for t in T:
    if t <= s + K and c:
        c -= 1
    else:
        s = t
        c = C - 1
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
# 乗せれるだけ乗っけるのがいいと思うだけなんだけどどうなんでしょう
# なんか実装しにくい 世界一プログラミングが下手
# 二重whileなんてやるからだ forでいいやろ
n, c, k = map(int, input().split())
ans = 0
arr = sorted([int(input()) for _ in range(n)])
cur_passenger = 0
limit = arr[0] + k
for i in range(n):
    if cur_passenger < c and arr[i] <= limit:
        cur_passenger += 1
        # print("{}番目の人は{}のバスに乗せた".format(i, ans))
    else:
        cur_passenger = 1
        limit = arr[i] + k
        ans += 1
        # print("{}番目の人を{}のバスの最初の客にした".format(i, ans))
# あぶれた人を救済
if cur_passenger > 0:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
passenger = sorted([int(input()) for _ in range(n)], reverse = True)
#cは一度に乗れる乗客の数
#kは時間の幅
count = 0
while passenger != []:
    bus = []
    time = passenger[0]
    count += 1
    while len(bus) != c and time - k <= passenger[0]:
        bus.append(passenger.pop(0))
        if passenger == []:
            break
print(count)

Submission status: Accepted

Solution code:


n, c, k = map(int, input().split())
passenger = sorted([int(input()) for _ in range(n)], reverse = True)
#n, c, k = map(int, "6 3 3".split())

#cは一度に乗れる乗客の数
#kは時間の幅
#passenger = [10, 8, 7, 6, 6, 2]
count = 0
while passenger != []:
    bus = []
    time = passenger[0]
    count += 1
    while len(bus) != c and time - k <= passenger[0]:
        bus.append(passenger.pop(0))
        if passenger == []:
            break

print(count)

Submission status: Accepted

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

print(ans+1)

Submission status: Accepted

Solution code:
# coding: utf-8
N, C, K = map(int, input().split())
T = []
for i in range(N):
    t = int(input())
    T.append(t)
T.sort()
# print(T)
ans = 0
idx = 0
s = T[0]
cnt = 1
for i in range(1,N):
    if cnt >= C:
        ans += 1
        cnt = 1
        s = T[i]
    else:
        if T[i] - s <= K:
            cnt += 1
        else:
            ans += 1
            cnt = 1
            s = T[i]
if cnt != 0:
    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()
time = T.pop(0)
people = 1
ans = 1
for t in T:
    if t <= time + K and people < C:
        people += 1
    else:
        time = t
        people = 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()
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)