Problem:


Score : 300 points

Problem Statement

Every day, N passengers arrive at Takahashi Airport.
The i-th passenger arrives at time T_i.

Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers.
Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport.
Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane.
For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).

When setting the departure times for buses under this condition, find the minimum required number of buses.
Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Constraints

2 \leq N \leq 100000

1 \leq C \leq 10^9

1 \leq K \leq 10^9

1 \leq T_i \leq 10^9

C, K and T_i are integers.

Input

The input is given from Standard Input in the following format:

N C K
T_1
T_2
:
T_N

Output

Print the minimum required number of buses.

Sample Input 1

5 3 5
1
2
3
6
12

Sample Output 1

3

For example, the following three buses are enough:

A bus departing at time 4.5, that carries the passengers arriving at time 2 and 3.

A bus departing at time 6, that carries the passengers arriving at time 1 and 6.

A bus departing at time 12, that carries the passenger arriving at time 12.

Sample Input 2

6 3 3
7
6
2
8
10
6

Sample Output 2

3



Sample input:
5 3 5
1
2
3
6
12


Sample output:
3

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
fstTime = 0
pasCnt= 0
ans = 1
for i in T:
  if fstTime == 0:
    fstTime = i
#  print(i - fstTime <= K , pasCnt <= C, fstTime, pasCnt)
  if i - fstTime <= K and pasCnt < C:
    pasCnt += 1
  else:
    ans += 1
    fstTime = i
    pasCnt = 1
print(ans)

Submission status: Accepted

Solution code:
import heapq
import sys
input = sys.stdin.readline
def main():
    N,C,K = map(int,input().split())
    pas = []
    for _ in range(N):
        pas.append(int(input()))
    heapq.heapify(pas)
    bus = []
    num = 1
    m = min(pas)
    while pas:
        a = heapq.heappop(pas)
        if len(bus) == C or a-m > K:
            num += 1
            bus = []
            bus.append(a)
            m = a
        else:
            bus.append(a)

    print(num)

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

    if i == N - 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()
H=T[0]
bus=1
x=0
for i in range(N):
  x+=1
  if T[i]>H+K or x>C:
    H=T[i]
    bus+=1
    x=1
print(bus)

Submission status: Accepted

Solution code:
N, C, K = tuple(map(int, input().split()))
T = [int(input()) for _ in range(N)]
T = sorted(T)
base = T[0]
count = 1
ans = 1
for i in range(1, N):
    if T[i] <= base + K and count < C:
        count += 1
        continue
    base = T[i]
    count = 1
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
N,C,K,*T=map(int,open(0).read().split());T.sort();B=M=L=0
for t in T:
 M+=1
 if M>C or t>L:B+=1;M=1;L=t+K
print(B)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
l = sorted([int(input()) for i in range(n)])
count = 1
pas = 0
now = l[0]
for i in range(len(l)):
    check = now + k
    if pas < c and l[i] <= check:
        pas += 1
    else:
        now = l[i]
        pas = 1
        count += 1
print(count)

Submission status: Accepted

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

if C == 1:
  print(N)
else:
  cnt = 0
  ans = 0
  left = 0
  right = 0
  for i in range(N):
    if left <= a[i] <= right:
      cnt += 1
      if cnt == C:
        left = 0
        right = 0
    else:
      left = a[i]
      right = a[i] + K
      cnt = 1
      ans += 1
    #print(left,right)
    #print(cnt)
    #print("------")
  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()

check=t[0]+k
kyaku=1
ans=1
for i in range(1,n):
    if t[i]<=check and kyaku<c:
        kyaku+=1
        continue
    check=t[i]+k
    kyaku=1
    ans+=1
print(ans)

Submission status: Accepted

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

B=0
L=0
ans=0
for T in TT:
  if B==0:
    L=T+K
    B=C-1
    ans+=1
  else:
    if L>=T:
      B-=1
    else:
      L=T+K
      B=C-1
      ans+=1
  #print(T,B,L)
print(ans)

Submission status: Accepted

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

arr = []

for i in range(n):
    arr.append(int(input()))

arr.sort()

cnt = 1

a = arr[0]

bc = 1

for i in range(1, n):

    if arr[i] - a <= k:
        bc += 1

        if bc > c:
            bc = 1
            a = arr[i]
            cnt += 1
    else:
        bc = 1
        a = arr[i]
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N,C,K=map(int,input().split())
T=sorted([int(input()) for j in range(N)])
Bcount=1
person=0
Time=T[0]
for i in T:
  if person < C:
    if i-Time > K:
      Bcount += 1
      person = 1
      Time=i
    else:
      person += 1
  else:
    Bcount += 1
    person = 1
    Time=i

print(Bcount)

Submission status: Accepted

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

bus = [T[0]]
count = 1

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

print(count)

Submission status: Accepted

Solution code:
# AGC011A - Airport Bus
def main():
    N, C, K, *T = map(int, open(0).read().split())
    T.sort()
    ans, cur, cnt = 0, T[0] + K, 0
    for i in T:
        if i > cur or cnt == C:  # need a new bus
            cur = i + K
            cnt = 1
            ans += 1
        else:  # ride on the current one
            cnt += 1
    print(ans + 1)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
Ts = []
for i in range(N):
  T = int(input())
  Ts.append(T)
Ts.sort()
r = 0
i = 0
while i < N:
  Imin = i
  Tmin = Ts[Imin]
  while i < N:
    if i < Imin+C and Ts[i] <= Tmin+K:
      i += 1
    else:
      break
  r += 1
print(r)

Submission status: Accepted

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

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

    ans = 1
    n = 1
    t0 = q.popleft()
    while q:
        t1 = q.popleft()
        if t1 <= t0 + K and n < C:
            n += 1
        else:
            ans += 1
            n = 1
            t0 = t1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

    ans = 1
    n = 1
    t0 = q.popleft()
    while q:
        t1 = q.popleft()
        if t1 < t0 + K + 1 and n < C:
            n += 1
        else:
            ans += 1
            n = 1
            t0 = t1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np
N,C,K = map(int, input().split())

Ts = []
for i in range(N):
  Ts.append(int(input()))
Ts = np.array(Ts)

Ts = np.sort(Ts)

ans = 1
t0 = None
for t in Ts:
  if t0 is None:
    t0 = t
    count = 1
  else:
    count += 1
    if (t<=t0+K)&(count<=C):
      pass
    else:
      ans += 1
      t0 = t
      count = 1
print(ans)

Submission status: Accepted

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

count = 1
passengers = 0
border = times[0] + k
for t in times:
    passengers += 1
    if c < passengers or border < t:
        count += 1
        passengers = 1
        border = t + k

print(count)

Submission status: Accepted

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

count = 0
passengers = 0
border = 0
for i in range(n):
    if border == 0:
        border = times[i] + k
    if c > passengers and border >= times[i]:
        passengers += 1
        if passengers == c:
            count += 1
            passengers = 0
            border = 0
    elif border < times[i]:
        count += 1
        passengers = 1
        border = times[i] + k

print(count + 1 if passengers > 0 else count)

Submission status: Accepted

Solution code:
# sys.stdin.readline
import sys

input = sys.stdin.readline


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

        T.sort()
        bus = 1
        p = 1
        start = T[0]
        for i in range(1, N):
            p += 1
            if T[i] > K + start or p > C:
                bus += 1
                p = 1
                start = T[i]

        print(bus)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Accepted

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

T.sort(reverse=True)
ans = 0
while T:
    t = T.pop()
    ans += 1
    for i in range(C - 1):
        if not T or T[-1] > t + K:
            break
        T.pop()
print(ans)

Submission status: Accepted

Solution code:
import sys
input==sys.stdin.readline
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]
t.sort()
inf=float("inf")
ans=0
tl=inf
m=0
for i in range(n):
    if tl<t[i]:
        ans+=1
        m=1
        tl=t[i]+k
    elif m==c:
        ans+=1
        m=1
        tl=t[i]+k
    else:
        m+=1
        if m==1:
            tl=t[i]+k
if m:
    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()

cur = T[0]
p = 0
cnt = 1

for t in T:
    p += 1
    if t > cur + K or p > C:
        cur = t
        p = 1
        cnt += 1
        
print(cnt)

Submission status: Accepted

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

    ans = 0
    tt = t[0]
    cc = 1
    for i in range(1, n):
        if tt + k < t[i] or c == cc:
            tt = t[i]
            ans += 1
            cc=0

        cc += 1

    print(ans+1)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

    ans = 0
    tt = t[0]
    cc = 1
    for i in range(1, n):
        if tt + k < t[i] or c == cc:
            tt = t[i]
            ans += 1
            cc = 1
        else:
            cc += 1

    print(ans+1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,c,k=list(map(int,input().split())) 
t_=sorted([int(input()) for x in range(n)])
cnt=1
num=[]
for i in t_:
	if len(num)==c:
		cnt+=1
		num=[i]
	elif len(num)!=0 and i>num[0]+k:
		cnt+=1
		num=[i]
	else:
		num.append(i)
print(cnt)

Submission status: Accepted

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

ti = t.pop()
limit = ti + k
np = 1
ans = 1
while len(t):
    ti = t.pop()
    if np == c or limit < ti:
        limit = ti + k
        ans += 1
        np = 0
    np += 1
print(ans)

Submission status: Accepted

Solution code:
N, C, K = [int(i) for i in input().split()]
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
first_passenger = 0
bus_cnt = 1
for i in range(N):
    if T[i] <= T[first_passenger] + K and i - first_passenger + 1 <= C:
        pass
    else:
        bus_cnt += 1
        first_passenger = i
print(bus_cnt)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,c,k = LI()
    t = IR(n)
    t.sort()
    i = 0
    ans = 0
    while i < n:
        i = min(i+c,bisect.bisect_right(t, t[i]+k))
        ans += 1
    print(ans)
    return
#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()

Submission status: Accepted

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

    dep = T[0]
    count = 1
    cap = 1
    i = 1
    while i < N:
        while i < N and cap < C and T[i] <= dep +K:
            cap += 1
            i += 1
        if i < N:
            dep = T[i]
            cap = 1
            count += 1
            i += 1
    return count

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

T.sort()
counter = 0
while len(T) > 0:
  if len(T) == 1:
    T.pop()
    counter += 1
  else:
    c = 1
    while c <= len(T)-1 and c < C:
      if T[c] - T[0] <= K:
        c += 1
      else:
        break
  
    del T[:c]
    counter += 1

print(counter)

Submission status: Accepted

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

ans = 0
bus = []

for i in range(n):
	if len(bus) == c:
		ans += 1
		bus = [t[i]]
	elif bus != [] and bus[0] + k < t[i]:
		ans += 1
		bus = [t[i]]
	else:
		bus.append(t[i])

print(ans+1)

Submission status: Accepted

Solution code:
#import pysnooper
import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n,c,k=map(int,input().split())
t=sorted([int(input().rstrip()) for _ in range(n)])
ans=0
now=[]
for i in range(n):
    if len(now)==c:
        ans+=1
        now=[t[i]]
    elif now!=[] and now[0]+k<t[i]:
        ans+=1
        now=[t[i]]
    else:
        now.append(t[i])
    #print(now)

print(ans+1)

Submission status: Accepted

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

T.sort()
cur, cnt, ans = T[0], 0, 1
for t in T:
    cnt += 1
    if t > cur + K or cnt > C:
        cur, cnt, ans = t, 1, ans + 1
print(ans)

Submission status: Accepted

Solution code:
import sys
from math import floor
input = sys.stdin.readline

def main():
    N, C, K = map(int, input().split())
    t = sorted([int(input()) for i in range(N)])

    i = 0
    ans = 0
    while i < N:
        lim = t[i] + K
        tmp = 0
        for j in range(i, N):
            if t[j] <= lim:
                tmp += 1
            else:
                i = j
                break
            if tmp == C or j == N-1:
                i = j+1
                break
        ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, C, K = map(int,input().split())
para = [int(input()) for i in range(N)]
para.sort()
cnt = 1
p = 1
b = [para[0]]
while p <= N-1 :  
    if para[p] <= b[0] + K :
        if len(b) < C :
            b.append(para[p])
            p += 1 
        else :
            b = []
            cnt += 1 
            b.append(para[p])
            p += 1  
    else :
        b = [para[p]]
        p += 1
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq, bisect


def solve(N: int, C: int, K: int, T: "List[int]"):
    T.sort()
    T.append(10000000000000)
    count = 0
    i = 0
    while i < N:
        time = T[i]
        for x in range(C):
            if not time <= T[i] <= time + K:
                count += 1
                break
            i += 1
        else:
            count += 1
    print(count)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    T = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, C, K, T)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
nums ,limit ,wait = map(int, input().split())
nums_ary = [0 for i in range(nums)]

for i in range(nums):
    nums_ary[i] = int(input())

nums_ary.sort()
nums_ary.append(10000000000000)
count = 0
i = 0
while i < nums:
    time = nums_ary[i]
    for x in range(limit):
        if not time <= nums_ary[i] <= time + wait:
            count += 1
            break
        i += 1
    else:
        count += 1
print(count)

Submission status: Accepted

Solution code:
N,C,K = map(int,input().split())
T = sorted(int(input()) for _ in [0]*N)
ans = 0
b = []
for t in T:
    if b and (len(b)==C or b[0]<t-K) :
        ans += 1
        b = []
    b.append(t)
if b:ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def sol():
    N, C, K = map(int, input().split())
    T = [0] * N

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

    T.sort(reverse=True)
    ans = 0

    nowTime = float('inf')
    nowCount = 0
    for t in T:
        if nowTime - K <= t and nowCount < C:
            nowCount += 1
            continue
        ans += 1
        nowTime = t
        nowCount = 1

    print(ans)

sol()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n, c, k = [int(i) for i in input().split()]
    t = [int(input()) for i in range(n)]
    t.sort()
    i = 0
    # 乗客カウント
    count = 0
    # 被ってる区間があるかどうか
    # 1  4
    # 3  5
    ans = 0
    while i < n:
        s = t[i] + k
        count = 0
        while i < n and count < c and t[i] <= s:
            count += 1
            i += 1
        ans += 1
        if i == n:
            break
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
###SPEED TEST###
#import sys
#input=sys.stdin.readline
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]
t.sort()
p=1
dt=t[0]+k
ans=0
for i in range(1,n):
    if p==c:
        p=1
        ans+=1
        dt=t[i]+k
    elif dt<t[i]:
        p=1
        ans+=1
        dt=t[i]+k
    else:
        p+=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()
p=1
dt=t[0]+k
ans=0
for i in range(1,n):
    if p==c:
        p=1
        ans+=1
        dt=t[i]+k
    elif dt<t[i]:
        p=1
        ans+=1
        dt=t[i]+k
    else:
        p+=1
print(ans+1)

Submission status: Accepted

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
N, C, K = map(int, input().split())
T = [0]*N
for i in range(N):
    T[i] = int(input())
T.sort()
count = 1
tmp = 0
_tmp = 0  # 乗せた人数、直前のバスまでに乗せた人数
while tmp < N-1:
    tmp += 1
    if (tmp - _tmp == C or T[tmp] - T[_tmp] > K):
        _tmp = tmp
        count += 1
print(str(count))

Submission status: Accepted

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

ans = 0
tmp = 0 #現在バス内で待っている人
time = 0 #次のバスの発車時間
for i in range(N):
    if tmp == 0: #バスの車内で待っている人がいないとき
        tmp += 1
        time = T[i] + K #次のバスの発車時間
        continue
    if tmp == C: #もう乗れないとき
        ans += 1
        tmp = 1
        time = T[i] + K
        continue
    if tmp < C: #まだ乗れるとき
        if T[i] > time: #次に来た乗客の時間が発車時刻より遅い時
            ans += 1
            tmp = 1
            time = T[i] + K
            continue
        else: #時間に間に合っている時
            tmp += 1

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

ans = 0
i = 0
while i < N:
    t = T[i] + K
    j = 0
    while i + j < N and T[i+j] <= t and j < C:
        j += 1
    ans += 1
    i += j
print(ans)

Submission status: Accepted

Solution code:
from collections import deque

def solve():
	n,c,k,*t = map(int,open(0).read().split())
	d = deque(sorted(t)+[float("inf")])
	fir = d[0]
	cnt = ans = 0
	while d:
		if d[0]-fir <= k:
			del d[0]
			cnt += 1
			if cnt == c:
				fir = d[0]
				cnt = 0
				ans += 1
		else:
			fir = d.popleft()
			cnt = 1
			ans += 1
	print(ans-(c==1))

	
if __name__=="__main__":
	solve()

Submission status: Accepted

Solution code:
from collections import deque
n,c,k,*t = map(int,open(0).read().split())
d = deque(sorted(t)+[float("inf")])
f = d[0]
cnt = ans = 0
while d:
	if d[0]-f <= k:
		del d[0]
		cnt += 1
		if cnt == c:
			f = d[0]
			cnt = 0
			ans += 1
	else:
		f = d.popleft()
		cnt = 1
		ans += 1
print(ans-(c==1))

Submission status: Accepted

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

for i in range(N):
  l.append(int(input()))

l.sort()

bus_c=0
t_lim=0
jou_c=0

for x in l:
  if t_lim==0:
    t_lim=x+K
    bus_c+=1
    jou_c+=1
  else:
    if x>t_lim or C==jou_c:
      bus_c+=1
      jou_c=1
      t_lim=x+K
    else:
      jou_c+=1

print(bus_c)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
lista=[int(input())for i in range(n)]
listb=sorted(lista)
count=0
bustime=0
buspeople=0
for i in listb:
    if buspeople==0 or bustime<i:
        count+=1
        buspeople=c-1
        bustime=i+k
    else :
        buspeople-=1
print(count)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
T = sorted([int(input()) for i in range(n)])
ans = 0
last = 0
jokyaku = 0
for t in T:
    jokyaku += 1
    if jokyaku == c or t > last:
        jokyaku = 0
        last = t + k
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n, c, k = map(int,input().split())
T = sorted([int(input()) for _ in range(n)])
num = 0
count = 0
h0 = T[0]
h = T[0]+k
l = [0]
for i in range(n):
  if h0 <= T[i] <= h and num < c:
    num += 1
  elif num >= c or T[i] > h:
    num = 1
    l.append(count)
    h0 = T[i]
    h = T[i]+k
print(len(l))

Submission status: Accepted

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

n, c, k = map(int, input().split())
T = [int(input()) for t in range(n)]
T.sort()
bus_count = 0
vacant_seat = 0
limit = 0

for t in T:
    if t > limit or vacant_seat == 0:
        bus_count += 1
        vacant_seat = c-1
        limit = t + k

    else:
        vacant_seat -= 1

print(bus_count)

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

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

T.sort()
ans = 1
cnt = 0
departure = T[0] + K
for t in T:
    cnt += 1
    if t > departure or cnt > C:
        ans += 1
        cnt = 1
        departure = t + K
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()

tp = 0
count = 0
wait = 0
pa = 0
for i in range(n):
    ti = t[i]
    if pa == 0:
        wait = 0
    else:
        wait += ti-tp
    pa += 1
    if pa == c+1 or wait > k: 
        count += 1
        pa = 1
        wait = 0
    tp = ti
print(count+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()

answer = 0
first = -K
rest = C
for t in T:
    if first + K >= t and rest > 0:
        # 乗れる
        rest -= 1
        continue
    # 乗れない
    answer += 1
    first = t
    rest = C-1

print(answer)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#AGC11 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
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

n,c,k = map(int,sys.stdin.readline().split())
t = [int(sys.stdin.readline()) for _ in range(n)]
t.sort()
ans = 0
time,passenger = 0,0
for i in range(n):
    if passenger == 0 or passenger == c or time + k < t[i]:
        passenger = 1
        ans += 1
        time = t[i]
    else:
        passenger += 1
print(ans)

Submission status: Accepted

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

T.sort()

l = []
ans = 0

for i in range(N):
    l.append(T[i])
#    print(l)
    if len(l) != 0:
        for j in range(len(l)):   
            if l[j] + K <= T[i] :
                a = l[j]
                for k in range(min(C, len(l))):
                    if l[0]  <= a + K:
                        l.pop(0)
                ans += 1
                if j >= len(l) - C:
                    break
            else:
                break

#print(l)

check = 0
while check == 0:
    a = l[0]
    for k in range(min(C, len(l))):
        if l[0]  <= a + K:
            l.pop(0)
    ans += 1
    if len(l) == 0:
        check = 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()
i = 0
ans = 0
time =0
p = 0

for i in range(N):
 
    if  p==0 or p ==C:
        ans = ans+1
        p =1
        time =T[i]+K
    elif p<C :
        if T[i]<=time:
            p +=1
        elif T[i]>time:
            ans =ans+1
            time=T[i]+K
            p =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 = sorted(t)
    left = 0
    right = 0
    ans = 0
    while 1:
        if right == n-1:
            if t[right]-t[right-1]>k:
                ans +=2
                break
            else:
                ans +=1
                break
        if t[right]-t[left]<=k and right-left+1<=c:
            right +=1
        else:
            ans +=1
            left = right
    print(ans)
if __name__ == "__main__":
    main()

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()
ans = 0
t_from = 0 #一人目の客がバスに乗った時間
p = 0 #乗客の数
for i in range(n):
        if p == 0:
                ans += 1
                p = 1
                t_from = t[i]
        elif p < c:
                if t_from + k >= t[i]: #乗せてもOK
                        p += 1
                else: # i番目の人は次のバスに乗る場合
                        ans += 1
                        t_from = t[i]
                        p = 1
        else:
                ans += 1
                p = 1
                t_from = t[i]


print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *

N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
i, ans = 0, 0
while i < N:
    i = min(i+C, bisect_right(T, T[i]+K))
    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()
time = T[0]
index = 0
buses = 1
passenger = 0
while index < N:
    if T[index] > time+K:
        buses += 1
        time = T[index]
        passenger = 0
    if passenger == C:
        buses += 1
        time = T[index]
        passenger = 0
    passenger += 1
    index += 1
if passenger == 0:
    print(str(buses-1))
else:
    print(str(buses))

Submission status: Accepted

Solution code:
# AGC011A - Airport Bus
import sys
input = sys.stdin.readline

def main():
    N, C, K = tuple(map(int, input().rstrip().split()))
    T = sorted(map(int, [input().rstrip() for _ in range(N)]))
    ans, cur, cnt = 0, T[0] + K, 0
    for i in T:
        if i > cur or cnt == C:  # need a new bus
            cur = i + K
            cnt = 1
            ans += 1
        else:  # ride on the current bus
            cnt += 1
    print(ans + 1)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# AGC011A - Airport Bus
import sys
input = sys.stdin.readline

def main():
    N, C, K = tuple(map(int, input().rstrip().split()))
    T = sorted(map(int, [input() for _ in range(N)]))
    ans, cur, cnt = 0, T[0] + K, 0
    for i in T:
        if i > cur:
            cur = i + K
            cnt = 1
            ans += 1
        else:
            if cnt != C:
                cnt += 1
            else:
                cur = i + K
                ans += 1
                cnt = 1
    print(ans + 1)


if __name__ == "__main__":
    main()

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
    remain = 0
    first = 0
    for t in T:
        if remain <= 0 or first + K < t:
            remain = C
            first = t
            ans += 1
        remain -= 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import deque
n,c,k=map(int,input().split())
l=sorted([int(input()) for _ in range(n)],reverse=True)
ans=0
d=deque(l)
while len(d)!=0:
    ans+=1
    t=d.popleft()
    cnt=1
    while len(d)!=0 and d[0]>=t-k and cnt<c:
        d.popleft()
        cnt+=1
print(ans)