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())
l=[int(input()) for x in range(n)]
l.sort()
flg=l[0]
bus=1
capa=1
for i in range(1,n):

    if capa==c:
        bus+=1
        capa=1
        flg=l[i]
    
    elif flg <= l[i] <= flg+k:
            capa+=1
    else:
        bus+=1
        capa=1
        flg=l[i]    
print(bus)

Submission status: Accepted

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

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

count = 1
bus = 1
start = t[0]
for i in range(1, n):
    if count == c:
        start = t[i]
        count = 1
        bus += 1
        
    elif start <= t[i] <= start + k:
        count += 1
    else:
        start = t[i]
        bus += 1
        count = 1

print(bus)

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:
N, C, K = [int(i) for i in input().split()]
T = sorted([int(input()) for i in range(N)])
ans = 1
limit = 0
ti = T[0]
for i in range(N - 1):
    limit += 1
    if ti + K < T[i + 1] or limit == C:
        ti = T[i + 1]
        ans += 1
        limit = 0
print(ans)

Submission status: Accepted

Solution code:
n,c,k= map(int,input().split())
t=sorted([int(input()) for i in range(n)])
cnt=1
lim=0
ti=t[0]
for i in range(n-1):
	lim+=1
	if ti+k<t[i+1] or lim==c:
		#print(t[i],cnt,lim)
		ti=t[i+1]
		cnt+=1
		lim=0

print(cnt)

Submission status: Accepted

Solution code:
# AGC 011 A - Airport Bus
n,c,k=map(int,input().split())
T=[int(input()) for i in range(n)]
T.sort()

until_next=0
cur_t=0
bus_fig=False
bus=0
bus_people=0

for i in range(n):
    cur_t=T[i]
    if bus_fig==False:
        bus+=1
        bus_people+=1
        until_next=T[i]+k
        bus_fig=True
    elif bus_fig==True:
        if bus_people<c:
            if cur_t<=until_next:
                bus_people+=1
                pass
            elif cur_t>until_next:
                bus_fig=True
                bus+=1
                bus_people=1
                until_next=T[i]+k
        else:
            bus_fig=True
            bus+=1
            bus_people=1
            until_next=T[i]+k
print(bus)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
s=[]
for i in range(n):
    s.append(int(input()))
s.sort()
ans=1
count=0
a=s[0]
for i in range(n):
    if s[i]-a>k:
        a=s[i]
        count=1
        ans+=1
    else:
        count+=1
    if count==c:
        if i!=n-1:
            count=0
            ans+=1
            a=s[i+1]
    #print(a,count,ans)
print(ans)

Submission status: Accepted

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

# greedy

N,C,K,*T = map(int,read().split())

T.sort()

bus_t = -K - 100
bus_c = C
answer = 0
for t in T:
    bl = (bus_t + K >= t) and (bus_c + 1 <= C)
    if bl:
        bus_c += 1
        continue
    answer += 1
    bus_t = t
    bus_c = 1

print(answer)

Submission status: Accepted

Solution code:
from bisect import bisect_right
N,C,K = map(int,input().split())
T = sorted([int(input()) for _ in range(N)])
cnt = 0
cur = 0
while cur<N:
    i = min(cur+C,N)-1
    if T[i]-T[cur]<=K:
        cnt += 1
        cur = i+1
    else:
        i = bisect_right(T,T[cur]+K)-1
        cnt += 1
        cur = i+1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
t_lim = 0
cnt = 0
for t in T:
    cnt += 1
    if t_lim == 0:
        t_lim = t+k
    if t > t_lim:
        ans += 1
        t_lim = t+k
        cnt = 1
    if cnt == c:
        ans += 1
        t_lim = 0
        cnt = 0
if cnt != 0:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, C, K = map(int, input().split(' '))
T = sorted([int(input()) for _ in range(N)])

buf = []
ans = 0
c, n = C, 0
for t in T:
    if c == C:
        c = 1
        n = t + K
        ans += 1

        # print(buf)
        # buf = [t]

    else:
        if t <= n:
            c += 1
            # buf.append(t)
        else:
            c = 1
            n = t + K
            ans += 1

            # print(buf)
            # buf = [t]

# print(buf)
print(ans)

Submission status: Accepted

Solution code:
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
ans = 0
bus = 0
bus_start = 0
passengers = 0
for t in T:
    if passengers == 0:
        bus_start = t
    if bus_start <= t <= bus_start + K:
        passengers += 1
    else:
        passengers = 1
        bus += 1
        bus_start = t
    if passengers == C:
        bus += 1
        passengers = 0
if passengers > 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()

bus = 0
time = 0
i = 0

while i < n:
    bus += 1  # とりあえず一番早く乗れる乗客を載せる
    time = T[i]
    passenger = 1
    while i < n - 1:  # 他の乗客が乗れるかチェック
        if T[i + 1] - time > k:  # 遠いところにいると乗せれない
            break
        if passenger >= c:  # 乗客がいっぱいだと乗せれない
            break
        passenger += 1
        i += 1
    i += 1

print(bus)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,c,k = map(int,input().split())
t = []
for i in range(n):
  t.append(int(input()))
t = sorted(t)
count = 1
first = t[0]
first_j = 0
for j in range(n):
  if t[j] - first > k:
    count += 1
    first = t[j]
    first_j = j
  elif j - first_j > c - 1:
    count += 1
    first = t[j]
    first_j = j
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

t.sort()
passenger = 0
start = t[0]
ans = 1


for i in t:
    if i - start > k or passenger == c:
        ans += 1
        passenger = 1
        start = i
    else:
        passenger += 1


print(ans)

Submission status: Accepted

Solution code:
from collections import deque

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

ans=0
q=deque()
q.append(T[0])
for Ti in T[1:]:
    if q[0]+K<Ti or len(q)==C:
        q.clear()
        ans+=1
    q.append(Ti)
ans+=1

print(ans)

Submission status: Accepted

Solution code:




def main()->None:
    N, C, K = map(int, input().split())
    range_N = range(N)
    T = [int(input()) for i in range_N] # バスの出発時刻
    T = sorted(T)
    
    bus = 0
    passenger = 0
    start = 0

    for i in range_N:
        if passenger == 0:
            start = T[i] + K
            passenger = 1

        elif passenger == C:
            bus += 1
            start = T[i] + K
            passenger = 1

        else:
            if T[i] > start:
                bus += 1
                start = T[i] + K
                passenger = 1

            else:
                passenger += 1
    print(bus+1)


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

ret = 1
cnt = 1
pre = T[0]
for i in range(1, N) :
  if cnt == C or T[i] > pre + K :
    ret += 1
    cnt = 1
    pre = T[i]
  
  else :
    cnt += 1
  
print(ret)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

t.sort()
p = t[0]
h = 1
ans = 1
for x in t[1:]:
    h += 1
    if x > p + k or h > c:
        ans += 1
        p = x
        h = 1

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)

bus = 0
jyokyaku = 0
start = 0

for i in range(n):
	if jyokyaku == 0:
		start = t[i] + k
		jyokyaku = 1
	
	elif jyokyaku == c:
		bus = bus + 1
		start = t[i] + k
		jyokyaku = 1
							
	else:	
		if t[i] > start:
			bus = bus + 1
			start = t[i] + k
			jyokyaku = 1
				
		elif t[i] <= start:
			jyokyaku = jyokyaku + 1

	#print(i,jyokyaku,bus,start)

print(bus+1)

Submission status: Accepted

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

cnt = 0
t = 0

while t < N:
    cnt += 1
    s = t
    while t < N and T[t] - T[s] <= K and t - s < C:
        t += 1
print(cnt)

Submission status: Accepted

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

cnt = 0
l, r = 0, 0
while l < n:
    b = 0
    while r < n and b + 1 <= c and t[r] - t[l] <= k:
        b += 1
        r += 1
    l = r
    cnt += 1
print(cnt)

Submission status: Accepted

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

count = []
ans = []
start = 0
for i in range(N):
    if abs(T[start] - T[i]) <= K and len(count) < C:
        count.append(T[i])
    else:
        ans.append(count)
        count = [T[i]]
        start = i
    
    if i == N-1:
        ans.append(count)

print(len(ans))

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
tl=[int(input()) for i in range(n)]
tl.sort()
i=0
bus_count=0
while i<n:
  bus_count+=1
  start=i
  while i<n and tl[i]-tl[start]<=k and i-start<c:
    i+=1
print(bus_count)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
tl=[int(input()) for i in range(n)]
tl.sort()
bef=tl[0]
people=1
bus_count=1
for i in range(n-1):
  if people<c and tl[i+1]-bef<=k:
    people+=1
    #print("ok")
    #print(people)
    #print(bef)
  else:
    bus_count+=1;bef=tl[i+1];people=1
    #print(i)
    #print("---")
print(bus_count)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, C, K = map(int, input().split())
res = 1
t = []
for _ in range(N):
  t.append(int(input()))
t.sort()
x = t.pop()
c = 1
for i in range(N - 1):
  y = t.pop()
  if abs(x - y) > K or (c >= C):
    res += 1
    x = y
    c = 0
  c += 1
print(res)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])
ans = 1
busNin = 0
busFirstp = 0
for i in range(n):
    if t[i]-t[busFirstp] > k or busNin == c:
        ans += 1
        busNin = 1
        busFirstp = i
        continue
    busNin += 1
print(ans)

Submission status: Accepted

Solution code:
#tiソート
#
import sys,bisect
input = sys.stdin.readline
n,c,k = map(int, input().split( ))
t = []
for i in range(n):
    ti = int(input())
    t.append(ti)

t.sort()
cnt = 0
fin = 0
while fin <n:
    fin2 = bisect.bisect_right(t,t[fin]+k)
    fin = min(fin+c,fin2)
    #print(t[fin:fin3],fin,fin3)
    #fin = fin3
    cnt+=1
print(cnt)

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()
ans = 1
head = T[0]
num = 1

for i in range(1,N):
    if num+1 > C or head+K < T[i]:
        ans += 1
        head = T[i]
        num = 1
    else:
        num += 1
        
print(ans)

Submission status: Accepted

Solution code:
N,C,K=map(int,input().split())
cus=[None]*N
for i in range(N):
  t=int(input())
  cus[i]=[t,t+K]
cus=sorted(cus,key=lambda x:x[1])

last=-1
ans=0
rest=0
for i in range(N):
  if rest==0 or last<cus[i][0]:
    last=cus[i][1]
    ans+=1
    rest=C-1
  elif rest>0:
    rest-=1
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

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


def AirportBus(x=0,ans=0):
    y = x
    for i in range(x, n):
        if t[x]+k < t[i] or i - x >= c:
          y = i
          break
    if y == x:
      print(ans+1)
      return
    ans += 1
    AirportBus(y,ans)
    
AirportBus()

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
s=[]
for i in range(n):
    s.append(int(input()))
s.sort()
ans=1
count=0
a=s[0]
for i in range(n):
    if s[i]-a>k:
        a=s[i]
        count=1
        ans+=1
    else:
        count+=1
    if count==c:
        if i!=n-1:
            count=0
            ans+=1
            a=s[i+1]
    #print(a,count,ans)
print(ans)

Submission status: Accepted

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

Ts = sorted(Ts)
bus_num = 1
bus_i = [1]
bus_t = Ts[0]
for t in Ts[1:]:
    if (t<=(bus_t+K)) & (len(bus_i) < C):
        bus_i.append(1)
    else:
        bus_i = [1]
        bus_t = t
        bus_num +=1
print(bus_num)

Submission status: Accepted

Solution code:
# 2019-11-22 16:56:24(JST)
import sys


def main():
    n, c, k, *T = [int(x) for x in sys.stdin.read().split()]
    T.sort()


    count = 0
    bus_count = 1
    t = T[0]
    for i in range(n):
        if T[i] - t > k:
            bus_count += 1
            count = 1
            t = T[i]
            continue
        count += 1
        if count > c:
            bus_count += 1
            count = 1
            t = T[i]
    
    print(bus_count)


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()
time = T[0] + K
answer = 0
passenger = 0
for i, t in enumerate(T):
    if time < t or passenger == C:
        answer += 1 # i-1までのバス
        passenger = 0
        time = t + K
    
    passenger += 1
    if i == N - 1:
        answer += 1
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, C, K = map(int, input().split())
T = []
for i in range(N):
    t1 = int(input())
    T.append(t1)
    
T.sort()
conut = 0
l = T[0]
n = 1
i = 0
ans = 0
while True:
    if T[i] - l > K:
        ans += 1
        n = 1
        l = T[i]
    elif n == C:
        if i <= N-2:
            l = T[i+1]
        ans += 1
        n = 0
    if i == N-1:
        if n > 0:
            ans += 1
        break
    i += 1
    n += 1    

print(ans)

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
t = list(int(input()) for _ in range(N))
t.sort()
ans = 0
s = t[0] + K
cnt = 0
cntF = True
for i in range(N):
    cntF = True
    if t[i] <= s:
        if cnt == C:
            cnt = 1
            ans += 1
            s = t[i] + K
            cntF = False
        else:
            cnt += 1
        continue

    cnt = 1
    s = t[i] + K
    ans += 1
if cntF:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:

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

T = []

for i in range(N):

    t = int(input())
    T.append(t)

T.sort()

ans = 0
now = 0
nt = T[0]
for i in range(N):

    if T[i] - nt > K:
        ans += 1
        nt = T[i]
        now = 1

    elif now == C:
        ans += 1
        nt = T[i]
        now = 1

    else:
        now += 1

print (ans+1)

Submission status: Accepted

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

T.sort()
T = [[t, t+K] for t in T]

bus = [[]]
bus_no = 0
limit = T[0][1]

for t in T:
    if (len(bus[bus_no]) < C and t[0] <= limit):
        bus[bus_no].append(t)
    else:
        bus.append([])
        bus_no += 1
        bus[bus_no].append(t)
        limit = t[1]

print(len(bus))

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
ans=0
if c==1:
  print(n)
  exit()
l=[]
for i in range(n):
  l.append(int(input()))
l.sort()
ride=[]
while l:
  a=l.pop(0)
  rode=a
  ride.append(a)
  while len(ride)<c:
    if l==[]:
      ans+=1
      break
    b=l[0]
    if b>ride[0]+k:
      ride.clear()
      ans+=1
      break
    l.pop(0)
    ride.append(b)
    if len(ride)==c:
      ans+=1
      ride.clear()
      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 = 0
ct = t[0]
cc = 0
for i in range(n):
  if cc == c or ct + k < t[i]:
    ans += 1
    ct = t[i]
    cc = 1
  else:
    cc += 1
print(ans + 1)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
t=[]
for _ in range(n):
  t.append(int(input()))
t=sorted(t)
i=0
ans=1
a=1
j=1
while j<=n-1:
  if t[i]+k>=t[j] and a<c:
    j=j+1
    a+=1
  else:
    ans+=1
    i=j
    j=j+1
    a=1
print(ans)

Submission status: Accepted

Solution code:
# AGC011
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort(reverse=True)
ans = 0
c_cnt = 0
now = T[0]
##print(C, K)
##print(T)

for i in range(N):
    if c_cnt >= C or now > T[i] + K:     # 乗れない時
        ans += 1
        c_cnt = 1
        now = T[i]
    else:
        c_cnt += 1
    if i == N - 1:
        if c_cnt != 0:
            ans += 1
        else:
            pass
    ##print(i, now, c_cnt, ans)
print(ans)

Submission status: Accepted

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

N, C, K = list(map(int, input().split()))
t_list = []

for _ in range(N):
    t = int(input().split()[0])
    t_list.append(t)

waiting_n = 0
dead_line_t = float("inf")
bus_count = 0
t_list = sorted(t_list)

for i, t in enumerate(t_list):
    if waiting_n == 0:
        dead_line_t = t + K

    waiting_n += 1

    if waiting_n >= C:
        # 定員に達したので出発する
        waiting_n = 0
        bus_count += 1
        continue

    if i == len(t_list) - 1:
        # 最後の一人はどのみち乗せるしかない
        bus_count += 1
        break

    if t_list[i + 1] > dead_line_t:
        # 出発しないと怒り出す客がいる
        waiting_n = 0
        bus_count += 1
        continue


ans = bus_count
print(ans)

Submission status: Accepted

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

t.sort()

passenger = 0
bus = 1
departure = t[0] + k

for i in range(n):
    if passenger < c and departure >= t[i]:
            passenger += 1
    else:
            bus += 1
            passenger= 1
            departure = t[i] + k
print(bus)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N,C,K=map(int,input().split())



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

T.sort()

t_ride=0
n_ride=0
count=0
for t in T:
    if t_ride==0:
        t_ride=t
        n_ride+=1
        count+=1
    else:
        if t-t_ride>K or n_ride==C:
            t_ride=t
            n_ride=1
            count+=1
        else:
            n_ride+=1
            
print(count)

Submission status: Accepted

Solution code:
n,c,k = map(int,input().split())
t = []
cnt,ans = 0,0
bt = 10**10
btl = []
for i in range(n):
    t.append(int(input()))

t.sort()

for i in range(n):
    if (t[i] > bt)|(cnt == c):
        ans += 1
        cnt,bt = 0,10**10
    if (bt == 10**10):
        bt = t[i]+k
        cnt += 1
    else:
        cnt += 1
        
if (cnt != 0):
    ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    A[i]=int(input())
A=sorted(A,reverse=True)

IND=0
total=0
while(len(A)>0):
    total+=1
    IND=A[0]-K
    count=0
    i=0
    while((len(A)>0)&(count<C)) :
        if(A[0]<IND):break
        A.pop(0)
        count+=1
print(total)

Submission status: Accepted

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

ans = 0
it = 0
while it < N:
  start = T[it]
  occupancy = 0
  while it < N and occupancy < C and T[it] <= start + K:
    occupancy += 1
    it += 1
  ans += 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()

    cnt = 0
    ans = 0
    dep = 0
    for e in t:
        if cnt == c or e > dep:
            dep = e + k
            ans += 1
            cnt = 0

        cnt += 1

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,c,k = inpl()
t = inpln(n)
t.sort()
u = [(i+k) for i in t]
res = 0
now = 0
while now < n:
    time = u[now]
    for i in range(c):
        if now == n:
            break
        if t[now] <= time:
            now += 1
        else:
            break
    res += 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()
ans=1
x=t[0]
y=0
for i in range(n-1):
    y+=1
    if t[i]-x>k:
        ans+=1
        x=t[i]
        y=1
    elif y==c:
        ans+=1
        x=t[i+1]
        y=0
print(ans+1 if t[-1]-x>k else 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
x=t[0]
y=0
for i in range(n-1):
    y+=1
    if t[i]-x>k:
        ans+=1
        x=t[i]
        y=1
    elif y==c:
        ans+=1
        x=t[i+1]
        y=0
print(ans+2 if t[-1]-x>k else ans+1)

Submission status: Accepted

Solution code:

n, c, k = map(int, input().rstrip("\n").split())
time = sorted(int(input()) for _ in range(n))

ans = 1

iter_ = iter(time)
top = next(iter_)
i = 1
next_ = next(iter_)

try:
    while True:

        while next_ - top <= k and i < c:
            next_ = next(iter_)
            i += 1

        ans += 1
        top = next_
        i = 1
        next_ = next(iter_)
except StopIteration:
    print(ans)

Submission status: Accepted

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

t.sort()
slash = 0
start = t[0]
bus = 1 
for i in range(1, n):
    if t[i] > start + k:
        start = t[i]
        slash += 1
        bus = 1
    elif bus < c:
        bus += 1
    else:
        start = t[i]
        slash += 1
        bus = 1

print(slash + 1)

Submission status: Accepted

Solution code:
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))

def main():
    #x,y = map(int,input().split())	x=1,y=2
    #a = input().split()	a=['1','2','3',...,'n']
    #a = list(map(int,input().split()))	a=[1,2,3,4,5,...,n]
    #li = input().split('T')	FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    #複数行の「1 2 3 4」型の入力を一配列に
    #x = sorted([list(map(int, input().split())) for _ in range(n)])
    #ソート x.sort(key=lambda y:y[1])
    # print("Yes")  print("No")  
    n,c,k = map(int,input().split())
    t=[]
    for i in range(n):
        t.append(int(input()))
    t.sort()
    ans=1
    x=[0,t[0]+k]
    for i in range(n):
        if x[0]==c:
            ans+=1
            x=[1,t[i]+k]
        elif t[i]<=x[1]:
            x[0]+=1
            if x[1]>t[i]+k:
                x[1]=t[i]+k
        else:
            ans+=1
            x=[1,t[i]+k]
    print(ans)
main()

Submission status: Accepted

Solution code:
from sys import stdin
N, C, K = [int(_) for _ in stdin.readline().rstrip().split()]
T = sorted([int(stdin.readline().rstrip()) for _ in range(N)])
i, ans = 0, 0
while i < N:
    ans += 1
    start = i
    while (i < N and T[i] - T[start] <= K and i - start < C):
        i += 1
print(ans)

Submission status: Accepted

Solution code:
n,c,k=map(lambda x: int(x), input().split())
t=[0]*n
for i in range(n):
    t[i]=int(input())
t.sort()
ans=1
sta=t[0]
man=1
for i in range(1,n):
    if t[i]<=sta+k and man<c:
        man+=1
    else:
        sta=t[i]
        man=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()
i = 0
start = 0
ans = 0
limit = C
for i in range(N - 1):
    # 定員余裕あり、時刻余裕ありの場合は乗車させる（定員から一人引く）
    if T[start] + K >= T[i + 1] and limit > 1 :
        limit -= 1
    # 定員余裕あり、時刻NGの場合は出発させる。
    elif T[start] + K < T[i + 1] and limit > 1:
        ans += 1
        limit = C
        start = i + 1
    # 定員余裕なしの場合は出発させる。
    elif limit == 1:
        ans += 1
        limit = C
        start = i + 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()
i = 0
start = 0
ans = 0
limit = C
for i in range(N - 1):
    if T[start] + K >= T[i + 1] and limit > 1 :
        limit -= 1
    elif T[start] + K < T[i + 1] and limit > 1:
        ans += 1
        limit = C
        start = i + 1
    elif limit == 1:
        ans += 1
        limit = C
        start = i + 1
if start != N:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
N,C,K=map(int,input().split())
T=[int(input()) for i in range(N)]
T.sort()
t=T[0]+K
a=1
h=1
for i in T[1:]:
    if t>=i and h<C:
        h+=1
    else:
        t=i+K
        h=1
        a+=1
print(a)

Submission status: Accepted

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

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

i = 0
result = 0
while(i < N):
    cur = l[i]
    psg = 0
    while(i < N and cur + K >= l[i] and psg < C):
        i += 1
        psg += 1
    result += 1

print(result)

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
i=0
y=c
while i<n:
    s=t[i]
    y=c-1
    i+=1
    while y>0 and i<n:
        if t[i]<=s+k:
            y-=1
            i+=1
        else:
            break
    ans+=1
print(ans)

Submission status: Accepted

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

N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
answer = 1
limit = T[0] + K
n = 0

for i in T:
    if i <= limit and n < C:
        n += 1
    else:
        answer += 1
        n = 1
        limit = i + K

print(answer)

Submission status: Accepted

Solution code:
def resolve():
    n, c, k = map(int, input().split())
    t = list(int(input()) for _ in range(n))
    t.sort()
    ans = 1
    limit = t[0] + k
    bus = 0
    for i in range(n):
        bus += 1
        if t[i] > limit or bus > c:
            limit = t[i] + k
            ans += 1
            bus = 1
    print(ans)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

ans = 0
i = 0
while i < n:
    s = T[i] + k
    j = 0
    while i+j < n and j < c and T[i+j] <= s:
        j += 1
    ans += 1
    i += j

print(ans)

Submission status: Accepted

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

for i in T[1:]:
    if P == C or i > N + K:
        B += 1
        P = 0
        N = i
    P += 1
print(B)

Submission status: Accepted

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

i = 0
ans = 0
while True:
    r = t[i] + k
    tmp = 0
    for j in range(i, i + c):
        if j >= n:
            break
        if t[j] <= r:
            tmp += 1
        else:
            break
    i += tmp
    ans += 1
    if i== n:
        break
print(ans)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
t=[]
bus=0
for _ in range(n):
	x=int(input())
	t.append(x)
t.sort()
cnt=0
timelimit=t[0]+k
for i in range(n):
	cnt+=1
	if t[i]>timelimit:
		bus+=1
		cnt=1
		timelimit=t[i]+k
	elif cnt==c:
		bus+=1
		cnt=0
		if i!=n-1:
			timelimit=t[i+1]+k
if cnt!=0:
	bus+=1
print(bus)