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
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


# ワーシャルフロイド (任意の2頂点の対に対して最短経路を求める)
# 計算量n^3 (nは頂点の数)
def warshall_floyd(d, n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

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

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定



# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
n, c, k = map(int, input().split())
t = sorted([int(input()) for i in range(n)])
ans = 1
cnt = 1
start = t[0]
for i in range(1, n):
    if t[i] - start > k or cnt == c:
        start = t[i]
        cnt = 1
        ans += 1
        continue
    cnt += 1
print(ans)

Submission status: Accepted

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

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

x = T[0]
p = 1
b = 1
for i in range(1, N):
    if T[i] <= x + K and p < C:
        p += 1
    else:
        x = T[i]
        b += 1
        p = 1
print(b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# AGC011 A Airport Bus
import bisect
from collections import deque

n, c, k = map(int, input().split())
t_list = [int(input()) for _ in range(n)]

t_list.sort()
t_list = deque(t_list)
ans = 0

while len(t_list) > 0:
    _tmp = t_list.popleft() + k
    _idx = bisect.bisect_right(t_list, _tmp)
    if c-1 <= _idx:
        for _ in range(c-1):
            t_list.popleft()
    else:
        for _ in range(_idx):
            t_list.popleft()
    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 = sorted(t)
ans = 0
i = 0
while i < n:
    j = 1
    while i + j < n and t[i + j] <= t[i] + k and j < c:
        j += 1
    i += j
    ans += 1 
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)]

t.sort()

q = deque(t)
cnt = 1
ans = 1
curr = q.popleft()

while q:
    tmp = q.popleft()
    if tmp - curr <= k and cnt < c:
        cnt += 1
    else:
        ans += 1
        cnt = 1
        curr = tmp

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

ans = 1
temp = [T[0], 0]
for t in T:
    if temp[0] + K < t or temp[1] + 1 > C:
        ans += 1
        temp = [t, 0]
    temp[1] += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, c, k, *t = map(int, open(0).read().split())
t.sort()
m = l = s = 0
for t in t:
    m += 1
    if m > c or t > l:
        s += 1
        m = 1
        l = t + k
print(s)

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
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 fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,C,K=MI()
    T=LIN(N)
    T.sort()
    angry = inf
    now = 0
    ans = 0
    for t in T:
        if(angry < t or now == C):
            ans += 1
            angry = inf
            now = 0
        angry = min(angry,t+K)
        now += 1
        # print(t,ans,angry)
    ans += angry < inf
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

N, C, K = map(int, sys.stdin.readline().strip().split())
T = []
for _ in range(N):
    T.append(int(sys.stdin.readline().strip()))

T.sort()
ans = 0
n = 0
left_min = float("inf")
for t_i in T:
    left_min = min(t_i, left_min)
    if left_min + K < t_i:
        ans += 1
        left_min = t_i
        n = 1
        continue

    n += 1
    if n == C:
        ans += 1
        n = 0
        left_min = float("inf")

if n > 0:
    ans += 1

print(ans)

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 = [int(readline()) for _ in range(n)]
t.sort()
ans = 1
tmp = [t[0], 0]
for tt in t:
    if tmp[0] + k < tt or tmp[1] + 1 > c:
        ans += 1
        tmp = [tt, 0]
    tmp[1] += 1
print(ans)

Submission status: Accepted

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

from collections import deque
n,c,k = list(map(int, input().split()))
t = deque(sorted([int(input()) for _ in range(n)]))

cnt=0
bus=[]
while t:
    flg=False
    t1=t.popleft()
    if not bus:
        bus.append(t1)
        flg=True
    elif t1-bus[0]<=k and len(bus)<c:
        bus.append(t1)
        flg=True

    if len(bus)>=c or t1-bus[0]>=k:
#        print('bus=',bus)
#        print('t1=',t1)
        cnt+=1
        bus.clear()

    if not flg:
        bus.append(t1)

if bus:
    cnt+=1
    
print(cnt)

Submission status: Accepted

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

t_list.sort()

ans = 1
c_limit = 1
t_limit = t_list[0] + k

for i in range(1, n):
    t = t_list[i]
    # 乗客が前の客の時間制限より大きいか、すでにバスが定員以上なら
    if t > t_limit or c_limit >= c:
        ans += 1
        c_limit = 1
        t_limit = t + k
    else:
        c_limit += 1

print(ans)

Submission status: Accepted

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

t_s = sorted(t_input)

ans = 1
c_limit = 1
t_limit = t_s[0]+k
for i in range(1,n):
    t = t_s[i]
    #乗客が前の客の時間制限より大きいか、すでにバスが定員以上なら
    if t>t_limit or c_limit>=c:
        ans+=1
        c_limit=1
        t_limit = t+k
    else:
        c_limit+=1
print(ans)

Submission status: Accepted

Solution code:
n,c,k = map(int,input().split())
list = [int(input()) for _ in range(n)]
sorted_list = sorted(list)
bus = 1
customer = 1
max_hour = sorted_list[0]+k
for i in sorted_list[1:]:
  if i > max_hour or customer >= c:
    bus+=1
    customer=1
    max_hour = i+k
  else:
    customer += 1
print(bus)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/agc011/tasks/agc011_a

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

schedule = []
for _ in range(n):
    t = int(input())
    schedule.append(t)
schedule.sort()

ans = 0
start = schedule[0]
p = 0
for i in range(n):
    s = schedule[i]
    if s <= start + k:
        p += 1
        if p == c:
            ans += 1
            p = 0
            if i + 1 == n:
                break
            start = schedule[i + 1]
    else:
        ans += 1
        start = schedule[i]
        p = 1
if p:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/agc011/tasks/agc011_a

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

schedule = []
for _ in range(n):
    t = int(input())
    schedule.append(t)
schedule.sort()
# schedule.append(float('inf'))

def check(num, schedule, c, k):
    bus = 0
    start = schedule[0]
    p = 0
    i = 0
    while i < len(schedule):
        s = schedule[i]
        if s <= start + k:
            p += 1
            i += 1
            if p == c:
                bus += 1
                p = 0
                if i == len(schedule):
                    break
                start = schedule[i]
        else:
            start = schedule[i]
            bus += 1
            p = 1
            i += 1
    if p:
        bus += 1
    if bus <= num:
        return True
    return False

l = 0
r = 10 ** 10
ans = float('inf')
while l <= r:
    mid = (l + r) // 2
    if check(mid, schedule, c, k):
        r = mid - 1
        ans = min(ans, mid)
    else:
        l = mid + 1

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

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

ans = 1
cnt = 0
# 最後にバスが出た時間
st = T[0]
for t in T:
    cnt += 1
    # バスが出てからK時間以上たつ or count が　C を越した場合
    if t - st > K or cnt > C:
        ans += 1
        st = t
        cnt = 1

print(ans)

Submission status: Accepted

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

    T.sort()

    ans,time,rider = 1,T[0],0
    for i in range(N):
        if T[i] <= time + K and rider < C:
            rider += 1
        else:
            ans += 1
            time = T[i]
            rider = 1

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# A - Airport Bus
# https://atcoder.jp/contests/agc011/tasks/agc011_a

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

T.sort()

ans = 1
cnt = 0
st = T[0]
for t in T:
  cnt += 1
  if t - st > k or cnt > c:
    ans += 1
    st = t
    cnt = 1

print(ans)

Submission status: Accepted

Solution code:
def answer(n, c, k, ts):
    ts.sort()
    bus = 1
    _c = 1
    standard = ts[0]
    for i in range(1, len(ts)):
        if ts[i] <= standard+k and _c < c:
            _c += 1
        else:
            _c = 1
            standard = ts[i]
            bus += 1
    return bus
    
n, c, k = map(int, input().split())
ts = []
for _ in range(n):
    ts.append(int(input()))
print(answer(n, c, k, ts))

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
l=sorted([int(input()) for i in range(a)])
ans=0
now=l[0]
cur=1
for i in range(1,a):
  x=l[i]
  if cur==b:
    now=x
    cur=1
    ans+=1
  elif x-now>c:
    now=x
    ans+=1
    cur=1
  else:
    cur+=1
print(ans+1)

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=sorted(T)
ans=0
mint=T[0]
now=1
for i in range(1,N):
    t=T[i]
    if now==C:
        ans+=1
        now=1
        mint=t
    elif t-mint<=K:
        now+=1
    else:
        ans+=1
        now=1
        mint=t
    if i==N-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)])
#print(T)
cnt = 0
i = 0
while i < n:
    start = i
    m = 1
    cnt += 1
    while i < n:
        if i - start < c and T[i] - T[start] <= k:
            i += 1
        else:
            break
print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, c, k = LI()
t = [I() for _ in range(n)]
t.sort()
tmp = 0
cnt = 0
ans = 0
if c == 1:
    print(n)
    quit()
for i in range(n):
    if t[i] <= tmp:
        cnt += 1
        if cnt == c:
            cnt = 0
            ans += 1
            if i + 1 < n:
                tmp = t[i+1] + k
            else:
                ans += 1
                break
    else:
        tmp = 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)])

bus = 1
tmp_bus = 1
bus_time = T[0] + K

for t in T[1:]:

    if tmp_bus < C and t <= bus_time:
        tmp_bus += 1
    else:
        bus += 1
        bus_time = t + K
        tmp_bus = 1

print(bus)

Submission status: Accepted

Solution code:
from math import ceil

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

d_t = T[0]
p = 1
ans = 1

for t in T[1:]:
    if p < C and t-d_t <= K:
        p += 1
    else:
        ans += 1
        d_t = t
        p = 1

print(ans)

Submission status: Accepted

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,c,k = MI()
T = CI(n)

ls = []
for i in range(n):
    s = T[i]
    t = T[i] + k
    ls.append( [s,t] )

ls = mysort(ls,1,False)

# print(ls)

bt = -1*INF
bus = 0
m = 0
for i in range(n):
    s = ls[i][0]
    t = ls[i][1]
    if s>bt:
        bus += 1
        m = 1
        bt = t
    else:
        m += 1
        if m>c:
            bus += 1
            m = 1
            bt = t

print(bus)

Submission status: Accepted

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

T = 0
cnt = 0
ans = 0
for i in range(n):
  if cnt == 0: #誰も待っていない
    T = t[i] + k
    cnt += 1
  elif t[i] <= T:
    cnt += 1
  elif t[i] > T:
    ans += 1
    cnt = 1
    T = t[i] + k
  if cnt == c:
    ans += 1
    T = 0
    cnt = 0
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()
prev = -1
r = 0
ans = 0
for t in T:
    if prev > 0 and t - prev > K:
        prev = t
        r = 1
        ans += 1
    elif prev < 0:
        prev = t
        ans += 1
        r = 1
    else:
        r += 1

    if r == C:
        prev = -1
        r = 0


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
wait_p=0
first_t=-1

for i in range(n):
    ti=t[i]
    if(first_t==-1):
        first_t=ti

    wait_p+=1

    if(ti > first_t+k):
        bus+=1
        first_t=ti
        wait_p=1

    if(wait_p >= c):
        bus+=1
        first_t=-1
        wait_p=0


if(first_t!=-1 or wait_p > 0):
    bus+=1

print(bus)

Submission status: Accepted

Solution code:
n,c,k = tuple(map(int,input().split()))
t = []

for i in range(n):
  t.append(int(input()))
t = sorted(t)
t_0 = t[0]
p = 1
ans = 0
for t_i in t[1:]:
  if p<c and t_i-t_0<=k:
    p+=1
  else:
    p = 1
    t_0 = t_i
    ans+=1
    
print(ans+1)

Submission status: Accepted

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

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

while now<N:
    ans += 1
    lim = T[now]+K
    
    for _ in range(C):
        if T[now]<=lim:
            now += 1
        else:
            break
        
        if now==N:
            break

print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,c,k=mp()
t=sorted([int(input()) for i in range(n)])
count=1
f=t[0]
ans=1
for i in range(1,n):
    count+=1
    d=t[i]-f
    if d>k or count>c:
        ans+=1
        count=1
        f=t[i]

print(ans)

Submission status: Accepted

Solution code:
N,C,K = [int(hoge) for hoge in input().split()]
ans = 0
time = -float("inf")
bus = 0
Ts = sorted([int(input()) for i in range(N)])
for T in Ts:
    if (T > time + K) or bus==C:
        ans += 1
        time = T
        bus = 1
    else:
        bus += 1
print(ans)

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
T = sorted([int(input()) for i in range(N)])
b = 0
i = 0
n = 1
t = T[0]
while i < N - 1:
    if n == C:
        b += 1
        n = 1
        i += 1
        t = T[i]
        if i == N - 1:
            b += 1
            break
        else:
            continue
    if t + K < T[i + 1]:
        b += 1
        n = 1
        i += 1
        t = T[i]
        if i == N - 1:
            b += 1
            break
        else:
            continue
    n += 1
    i += 1
    if i == N - 1:
        b += 1
        break

print(b)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque

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

l = deque([])
cnt = 0
for i in range(n):
    if len(l) > 0:
        if l[0] + k < t[i]:
            cnt += 1
            l = deque([])
    l.append(t[i])

    if len(l) >= c:
        cnt += 1
        l = deque([])
if len(l) > 0:
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N,C,K=list(map(int,input().split()))
import sys
l=[r.rstrip() for r in sys.stdin.readlines()]
l=list(map(int,l))
l.sort()
ans=0
now=0
for i in range(N):
   X=l[now]
   for j in range(C):
      if X <= l[now] <= X+K:
         now+=1
         if now==N:
            break
      else:
         break
   ans+=1
   if now==N:
      break
print(ans)

Submission status: Accepted

Solution code:
n , c , k = map(int,input().split()) # n人数、cバスに乗れる数、k怒り出す時間
t = [int(input()) for _ in range(n)]

#n,c,k = 6,3,3
#t = [7,6,2,8,10,6]

t = sorted(t)

jyokyaku = 0
bus = 0
for i in t:

  if jyokyaku == 0: #バス最初の乗客
    bus += 1
    angrytime = i + k
    jyokyaku += 1
    if jyokyaku == c: #定員になりバス出発
      jyokyaku = 0

  else: 
    if i <= angrytime: #最初の乗客がキレる前だったら乗れる
      jyokyaku += 1
      if jyokyaku == c: #定員になりバス出発
        jyokyaku = 0

    else: #もうバス出発してたので最初の乗客になった
      bus += 1
      jyokyaku = 1
      angrytime = i + k

print(bus)

Submission status: Accepted

Solution code:
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

n,c,k = MI()
t = sorted([I() for _ in range(n)])

cnt = 1
b = 1
bt = t[0]+k
for i in range(1, n):
    if cnt == c or t[i] > bt:
        b += 1
        bt = t[i]+k
        cnt = 1
    else:
        cnt += 1
print(b)

Submission status: Accepted

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

ans = 0
c = 0
s = 0

for t in T:
    if (s != 0) and (s + K < t):
        s = 0
        c = 0
        ans += 1

    if s == 0:
        s = t
    c += 1

    if c == C:
        s = 0
        c = 0
        ans += 1
    #print(t, s, c, ans)

if s != 0:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
p = 0
bus = 0
time = 0
b = sorted([int(input()) for i in range(N)])
for i in range(N):
    a = b[i]
    if a - time > K or p == C:
        p = 0
    if p == 0:
        time = a
        bus += 1
    p += 1
print(bus)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# sys.stdin.readline()
import numpy as np
import sys
import math
input = sys.stdin.readline
n,c,k = map(int,input().split())
A = [int(input()) for i in range(n)]
a = sorted(A)
ans = 0
time = 0.1 
num = 0
for i in range(n):
    if ans == 0:
        ans +=1
        time = a[0] 
        num +=1
    elif ans != 0 and a[i] <= time +k and num < c :
        num +=1
    elif  ans != 0 and (c <=num  or  time +k <=a[i]):
      
        time = a[i] 
        num = 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
pt = t[0]
cnt = 1

for i, ct in enumerate(t[1:]):
    if ct - pt > K:
        ans += 1
        cnt = 1
        pt = ct
    elif ct - pt <= K and cnt <= C:
        if cnt == C:
            ans += 1
            cnt = 0
            pt = ct
        cnt += 1
        
if cnt > 0:
    ans += 1
    
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    n, c, k = MI()

    T = [-1] * n
    for i in range(n):
        T[i] = II()
    T = sorted(T)

    bus_cnt = 1
    person_cnt = 0
    th = T[0] + k
    for i in T:
        # print(i, th, bus_cnt, person_cnt)
        if i > th or person_cnt + 1 > c:
            bus_cnt += 1
            person_cnt = 1
            th = i + k
        else:
            person_cnt += 1
    print(bus_cnt)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    n, c, k = MI()

    T = [-1] * n
    for i in range(n):
        T[i] = II()
    T = sorted(T)

    bus_cnt = 1
    person_cnt = 0
    th = T[0] + k
    for i in T:
        # print(i, th, bus_cnt, person_cnt)
        if i <= th:
            if person_cnt + 1 > c:
                bus_cnt += 1
                th = i + k
                person_cnt = 1
            else:
                person_cnt += 1
        else:
            bus_cnt += 1
            person_cnt = 1
            th = i + k
    print(bus_cnt)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
arrivals = {}
for _ in range(n):
    t = int(input())
    if t in arrivals:
        arrivals[t] += 1
    else:
        arrivals[t] = 1
data = sorted(arrivals.keys())
ans = 0
current_bus_seats = c
bus_wait_from = data[0]
for time in data:
    ppl = arrivals[time]
    if current_bus_seats != c:
        if time - bus_wait_from > k:
            ans += 1
        else:
            if ppl <= current_bus_seats:
                current_bus_seats -= ppl
                continue
            else:
                ppl -= current_bus_seats
                ans += 1
    current_bus_seats = c
    bus_wait_from = time
    d, m = divmod(ppl, c)
    ans += d
    current_bus_seats -= m
if current_bus_seats < c:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
# A - Airport Bus

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

for i in range(N):
    if c==0 or T[i]>dead_time:
        dead_time = T[i]+K
        ans += 1
        c = 0
    c = (c+1)%C

print(ans)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
ans=0
cnt=1
t=sorted([int(input())for s in range(n)])
while t:
    now=t.pop()
    ans+=1
    while t and cnt<c and t[-1]+k>=now:
        cnt+=1
        t.pop()
    cnt=1

print(ans)

Submission status: Accepted

Solution code:
import bisect

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

ans = 0
remain = c-1
if c==1:
	print(n)
	exit()
time = t[0]
for i in range(1,len(t)):
	if time+k<t[i]:
		time = t[i]
		remain = c
		ans+=1
	if remain==0:
		remain=c
		time = t[i]
		ans+=1
	remain-=1

print(ans+1)