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=sorted([int(input()) for _ in range(N)])
l,r,ans=0,0,0
while l<N:
    while r<N and r-l+1<=C and T[r] <= T[l]+K:
        r+=1
    ans+=1
    l=r
print(ans)

Submission status: Accepted

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

t_sorted = sorted(t_list)

ans = 1
bus = 1
timer = 0
for i in range(1, len(t_sorted)):
    bus += 1
    timer += t_sorted[i] - t_sorted[i - 1]
    if bus > c or timer > k:
        ans += 1
        bus = 1
        timer = 0

print(ans)

Submission status: Accepted

Solution code:

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

ans = 1
passed = 0
nums = [ int(input()) for _ in range(N)]
nums.sort()
before = nums[0]
c = 1

for t in nums[1:]:

    c += 1
    passed += t - before
    if passed > K or c > C: #次のバス
        c = 1
        passed = 0
        ans += 1
    before = t
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
now_t = T[0] + K
now_p = 1

for t in T:
    if now_t < t or now_p > C:
        ans += 1
        now_p = 1
        now_t = t + K
    now_p += 1

print(ans)

Submission status: Accepted

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

T.sort()

first = True
ans = 0
peo = 0
limit = T[-1]
for t in T:
    if peo == C or t > limit:
        ans += 1
        first = True
    if first:
        limit = t + K
        peo = 1
        first = False
    elif t <= limit:
        peo += 1

if peo > 0:
    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
p=0
q=0
for i in range(n):
    if p==0:
        p=t[i]
        ans+=1
        q=i
    elif t[i]>p+k or i>=q+c:
        p=t[i]
        ans+=1
        q=i
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
c = 0
now = T[0]
for i in range(N):
    if c == C:
        c = 0
        ans += 1
        now = T[i]
    if T[i] <= now + K:
        c += 1
    else:
        ans += 1
        c = 1
        now = T[i]
print(ans)

Submission status: Accepted

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

times = [int(input()) for _ in range(n)]
times.sort()

ans = 0
t_first_arrived = times[0]
num_first_arrived = 0

for i in range(n):
	if (times[i] > t_first_arrived + k):
		ans += 1
		t_first_arrived = times[i]
		num_first_arrived = i

	elif i >= num_first_arrived + capa:
		ans += 1
		t_first_arrived = times[i]
		num_first_arrived = i

ans += 1

print(ans)

Submission status: Accepted

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

ans=0
c=0
t=0

for i in range(N):
    if c==0:
        ans+=1
        t=T[i]

    c+=1

    if c==C or T[i+1]>t+K:
        c=0

print(ans)

Submission status: Accepted

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

import sys

sys.setrecursionlimit(10**7)


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    num_psgr, bus_cap, max_itvl = read_h()
    arv_tms = sorted(read_v(num_psgr))

    num_bus = 1
    cur_bus_cap = bus_cap - 1
    deadline = arv_tms[0] + max_itvl
    for t in arv_tms[1:]:
        if t <= deadline and cur_bus_cap >= 1:
            cur_bus_cap -= 1
        else:
            num_bus += 1
            cur_bus_cap = bus_cap - 1
            deadline = t + max_itvl

    print(num_bus)


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

result = 0
wating = 0
first = None
for i in range(N):
    if wating == 0:
        first = i
        wating = 1
    elif T[first] + K < T[i]:
        result += 1
        first = i
        wating = 1
    else:
        wating += 1
    if wating == C:
        result += 1
        first = None
        wating = 0
if wating > 0:
    result += 1
print(result)

Submission status: Accepted

Solution code:
from sys import stdin
N,C,K = [int(x) for x in stdin.readline().rstrip().split()]
 
data = []
for _ in range(N):
    data.append(int(input()))
data = sorted(data)
ans = 0
time = 0
buss = 0
 
for ind,i in enumerate(data):
    if buss == 0:
        time = i
    if time + K >= i:
        buss += 1
        if ind == N - 1 and time != i:
          ans += 1
    else:
        buss = 1
        tmp = time
        time = i
        ans += 1
        if ind == N - 1 and time - tmp > K:
            ans += 1
        
    if buss == C:
        if ind == N - 1 and i != time:
          ans -= 1
        time = i
        ans += 1
        buss = 0
    #print(time,buss,ans)
print(ans)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
a=[int(input())for _ in range(n)]
a.sort()
t=a[0]
ans=0
cc=1
for i in range(1,n):
  tt=a[i]
  if t+k<tt or cc==c:ans+=1;t=tt;cc=1
  else:cc+=1
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.sort()
cnt=1
bus=0
for j in range(N):
  if bus==0:
    start=T[j]
    bus+=1
  elif start+K>=T[j] and bus < C:
    bus+=1
  else:
    cnt+=1
    bus=1
    start=T[j]

print(cnt)

Submission status: Accepted

Solution code:
row = list(map(int, input().split()))
T = [input() for i in range(row[0])]
T = list(map(int, T))
T.sort()

sub = []
for i in range(row[0]-1):
    sub.append(T[i+1]-T[i])
i = 0
sum = 0
C_count = 0
count = 0
while i < len(sub):
    sum += sub[i]
    C_count += 1
    if sum > row[2] or C_count == row[1]:
        sum = 0
        C_count = 0
        count += 1
        i += 1
    else:
        i += 1
print(count+1)

Submission status: Accepted

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

T.sort()

bus=-10**9
cnt=0
ans=0
for t in T:
    if t>bus or cnt>=C:
        bus=t+K
        cnt=1
        ans+=1
    else:
        cnt+=1

print(ans)

Submission status: Accepted

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

t_sorted= sorted(t)
bus_num=0
i=0

while i < n:
  j=1
  while j < c:
    if i+j >= n:
      break
    if (t_sorted[i] + k >= t_sorted[i+j]):      
      j+=1      
    else:
      break      
  bus_num+=1
  i+=j
print(bus_num)

Submission status: Accepted

Solution code:
N,C,K = [int(x) for x in input().split()]
T = [int(input()) for _ in range(N)]
T.sort()
cnt = 0
first = -float('inf')
peop = 0
for i in T:
    if(i-first>K or peop>=C):
        cnt += 1
        first = i
        peop = 1
    else:
        peop += 1
print(cnt)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
l = [int(input()) for i in range(n)]
l.sort()
count = 0
first = l[0]
people = 1
count = 1
for i in range(1, n):
    if people < c and l[i] - first <= k:
        people += 1
    else:
        first = l[i]
        people = 1
        count += 1
print(count)

Submission status: Accepted

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

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

first=t[0]
people=1
count=1

for i in range(1,n):
  if people<c and t[i]-first<=k:
    people +=1
  else:
    first=t[i]
    people =1
    count+=1
print(count)

Submission status: Accepted

Solution code:
def solve(n, c, k, t):
    t = list(sorted(t))
    ans = 0
    i = 0
    while i < n:
        num = 0
        threshold = t[i] + k
        while (i < n) and (t[i] <= threshold) and (num < c):
            num += 1
            i += 1
        ans += 1
    return ans

n, c, k = map(int, input().split())
t = [int(input()) for i in range(n)]
print(solve(n, c, k, t))

Submission status: Accepted

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

for i in range(1, N):
    nowtime = T[i]
    tmp += 1   
    if tmp > C or nowtime - mintime > K:
        mintime = nowtime
        ans += 1
        tmp = 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
def m():
    ans = 0
    time = 0
    while time < N:
        high = T[time] + K
        for i in range(C):
            if time >= N:
                break
            if T[time] <= high:
                time += 1
            else:
                break
        ans += 1
    return ans
print(m())

Submission status: Accepted

Solution code:
passengers, bus_size, time_lim = map(int, input().split())
pass_list = [int(input()) for passenger in range(passengers)]
pass_list.sort()
front = 0
now = 0
cnt = 0
ans = 0
for psngr_lst in pass_list:
    if cnt == 0:
        front = psngr_lst
        now = psngr_lst
        cnt += 1
    elif cnt == bus_size:
        front = psngr_lst
        now = psngr_lst
        cnt = 1
        ans += 1
    elif now - front <= time_lim:
        if psngr_lst - front <= time_lim:
            now = psngr_lst
            cnt += 1
        else:
            front = psngr_lst
            now = psngr_lst
            cnt = 1
            ans += 1
if cnt:
    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 = 0
i = 0
while i < n:
    ans += 1
    m = t[i]
    cnt = 0
    while i < n and m <= t[i] <= m + k and cnt < c:
        cnt += 1
        i += 1
print(ans)

Submission status: Accepted

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

T = [int(input()) for i in range(N)]
sort_T = sorted(T)
a = 1 #バスの乗車人数
cnt = 1 #バスの台数
t = sort_T[0] + K #バスの一人目の到着時刻

for i in range(1,N):
    if a < C and sort_T[i] <= t:
        a +=1
    else:
        a = 1
        cnt += 1
        t = sort_T[i] + K

print(cnt)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

t.sort()

ans = 0
while t:
    x = t[-1][0]
    ans += 1
    for i in range(c):
        if t:
            if t[-1][0] <= x <= t[-1][1]:
                t.pop()
            else:
                break

print(ans)

Submission status: Accepted

Solution code:
n,c,k = map(int, input().split())
tl = [int(input()) for _ in range(n)]
tl.sort(reverse=True)
cnt = 0
while tl:
  t = tl.pop()
  cnt += 1
  for _ in range(c-1):
    if tl and tl[-1] <= t+k:
      tl.pop()
    else:
      break
print(cnt)

Submission status: Accepted

Solution code:
n, c, k = list(map(int, input().split()))
t = sorted([int(input()) for i in range(n)], reverse=True)
result = 1
bus = 1
time = t[0]
for i in range(1, n):
  if bus + 1 > c or time-t[i] > k:
    time = t[i]
    result += 1
    bus = 1
  else:
    bus += 1
print(result)

Submission status: Accepted

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

ans=0
nexttime=0
people=0
for t in T:
  if t>nexttime:
    nexttime=t+K
    ans+=1
    people=0
  people+=1
  if people==C:
    nexttime=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()

cnt = 0
tmp = []
for i in T:
    if tmp != [] and (min(tmp) + K < i or len(tmp) == C):
        cnt += 1
        tmp = [i]
    else:
        tmp.append(i)

if tmp != []:
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
A - Airport Bus
https://atcoder.jp/contests/agc011/tasks/agc011_a

"""
import sys


def solve(N, C, K, T):
    ans, i, j = 0, 0, 0
    while i < N:
        while j < N and i+C > j and T[i]+K >= T[j]:
            j += 1
        ans += 1
        i = j
    return ans


def main(args):
    N, C, K = map(int, input().split())
    T = sorted([int(input()) for _ in range(N)])
    ans = solve(N, C, K, T)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

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

s = 1
p = 1
w = a[0]+k 
for t in a[1:]:
  if p == c or t > w:
    p = 1
    s += 1
    w = t+k
  else:
    p += 1
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,C,K=map(int,input().split())
T=sorted([int(input()) for _ in range(N)])
First=T[0]
bus_rider=1
bus_cnt=1
for i in range(1,N):
    if bus_rider<C and T[i]-First<=K:
        bus_rider+=1
    else:
        First=T[i]
        bus_rider=1
        bus_cnt+=1
print(bus_cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    [N, C, K] = [int(i) for i in input().split()]

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

    counter = 1

    num_people = 0

    flag = False

    for time in T:
        num_people += 1
        if flag:
            if time - first_time <= K and num_people <= C:
                continue
            else:
                counter += 1
                num_people = 1
                first_time = time

        else:
            first_time = time
            flag = True

    print(counter)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    [N, C, K] = [int(i) for i in input().split()]

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

    counter = 1

    num_people = 0

    flag = False

    for num in T:
        num_people += 1
        if flag:
            if num - first_time <= K and num_people <= C:
                continue
            else:
                counter += 1
                num_people = 1
                first_time = num

        else:
            first_time = num
            flag = True

    print(counter)

Submission status: Accepted

Solution code:
N,C,K = [int(s) for s in input().split()]
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
 
pas = 0
leave = T[0]
ans = 1
 
for t in T:
    if pas == C or K < t - leave:
        leave = t
        ans += 1
        pas = 0
    pas += 1
print(ans)

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
flag = True
pass_num = 0
count = 1
for t in sorted([int(input()) for _ in range(N)]):
    if flag:
        first_pass_time = t
        flag = False
    if t - first_pass_time > K or pass_num == C:
        first_pass_time = t
        pass_num = 0
        count += 1
    pass_num += 1
print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in read(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[fill_value]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    N, C, K = readi(3)
    ts = sorted(readi(N))
    ans = 1
    diff = 0
    c = 1
    for i in range(N - 1):
        diff += ts[i + 1] - ts[i]
        dbg(i=i, diff=diff, c=c)
        if diff > K or c == C:
            dbg(ii=i)
            ans += 1
            diff = 0
            c = 1
        else:
            c += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
Ts = [int(input()) for _ in range(N)]
Ts.sort()
front = 0
now = 0
cnt = 0
ans = 0
for i in Ts:
    if cnt == 0:
        front = i
        now = i
        cnt += 1
    elif cnt == C:
        front = i
        now = i
        cnt = 1
        ans += 1
    elif now - front <= K:
        if i - front <= K:
            now = i
            cnt += 1
        else:
            front = i
            now = i
            cnt = 1
            ans += 1
if cnt:
    ans += 1
print(ans)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
T = []
for i in range(N):
    T.append(int(input()))
sorted_T = sorted(T)
bus_count = 1
pas_count = 0
bus_start = sorted_T[0]
for t in sorted_T:
    if pas_count == C or t - bus_start > K:
        bus_count += 1
        pas_count = 0
        bus_start = t
    pas_count += 1
print(bus_count)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
t = []
for i in range(n):
  t.append(int(input()))
t.sort()
person = 0
firsttime = 0
ans = 0
for i in range(n):
  if person == 0:
    firsttime = t[i]
    person += 1
  elif person <= c-1 and (firsttime + k) >= t[i]:
    person += 1
  else:
    person = 1
    firsttime = t[i]
    ans += 1
    
if person != 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)]
S=sorted(T)
B=0
first=-1
board=0
for i in range(N):
	if first==-1:
		first=S[i]
		board+=1
		B+=1
	elif board<C and S[i]-first<=K:
		board+=1
	else:
		first=S[i]
		board=1
		B+=1
print(B)

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)

bus_time = T[0]
bus_people = 1
c = 1
for i in range(1,N):
    bus_people += 1
    if T[i] > bus_time + K or bus_people > C:
        bus_time = T[i]
        bus_people = 1
        c += 1

print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
T=[int(input()) for i in range(n)]
T.sort()
count=1
t=T[0]
number=1
for i in range(1,n):
  if T[i]-t>k or number==c:
    count+=1
    t=T[i]
    number=1
  else:
    number+=1
print(count)

Submission status: Accepted

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

T.sort()
ans = 0
index = 0
while index < N:
    bus = T[index] + K
    for i in range(C):
        if index+i < N and T[index+i] > bus:
            i -= 1
            break
    index += i+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()
ans = 0
i = 0
while i<n:
    time = t[i]
    for j in range(0,c+1):
        if j>c or not t[i+j]-time<=k:
            ans += 1
            i += j
            break
        if (i+j)==(n-1):
            ans += 1
            i += j+1
            break
        if j==c:
            ans += 1
            i += j
print(ans)

Submission status: Accepted

Solution code:
n,c,k=map(int,input().split())
arr=[int(input()) for _ in range(n)]
arr=sorted(arr)
pos=0
cnt=0
for i in range(n):
  if pos==i:
    for j in range(c):
      if i+j==n:
        break
      if arr[i+j]-arr[i]>k:
        pos=pos+j
        break
    else:
      pos=pos+c
    cnt+=1
  else:
    continue
print(cnt)

Submission status: Accepted

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

T.sort()
ans = 1
p = T[0]
count = 1
for i in range(1,N):
    if T[i]-p > K:
        ans += 1
        count = 1
        p = T[i]
    else:
        if count < C:
            count += 1
        else:
            ans += 1
            count = 1
            p = T[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

i = 0
n_b = 0
n_passenger_on_waiting_bus = 0
departure_limit=-1

while i < N:
  if T[i] > departure_limit or n_passenger_on_waiting_bus == C:
    n_b +=1
    n_passenger_on_waiting_bus = 1
    departure_limit = T[i] + K
  else:
    n_passenger_on_waiting_bus += 1
  i += 1
    
print(n_b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])
bus = 0
cus = 0
lmt = T[0] + k
for t in T:
    if cus == 0 or t > lmt:
        bus += 1
        cus = 1
        lmt = t + k
    else:
        cus +=1
    
    if cus == c:
        cus = 0
print(bus)

Submission status: Accepted

Solution code:
import bisect
def solve():
  n,c,k = (int(i) for i in input().split())
  t = [int(input()) for i in range(n)]
  t = sorted(t,reverse = True)
  ans = 0
  
  while t:
    ans += 1
    customer = t.pop(0)
    if len(t) >= 1:
     for i in range(c-1):
      if customer  <= t[0] + k:
        t.pop(0)
      else:
        break
      if len(t) == 0:
        break
  print(ans)
  
solve()

Submission status: Accepted

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

bus = 0
i = 0
while i < N:
    bus += 1
    start = i
    while i < N and T[i] - T[start] <= K and i - start < C:
        i += 1
print(bus)

Submission status: Accepted

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

times = [int(input()) for _ in range(n)]
times.sort()

first = times[0]
cnt = 1
result = 0
for t in times[1:]:
    if t > first + k or cnt >= c:
        first = t
        cnt = 1
        result += 1
    else:
        cnt += 1
print(result + 1)

Submission status: Accepted

Solution code:
N,C,K = map(int,input().split())
t = [int(input()) for _ in range(N)]
t.sort()
L = 0
R = N-1
answer = 0
nextLeft = True

while L<=R:
    answer += 1
    if nextLeft:
        # print(L,R)
        nextLeft = False
        TLeft = t[L]
        count = 1
        L += 1
        while count < C:
            if L == N:
                break
            if t[L] <= TLeft + K:
                count += 1
                L+=1
            else:
                break
    else:
        # print(L,R)
        nextLeft = True
        TRight = t[R]
        count = 1
        R -= 1
        while count < C:
            if R == -1:
               break 
            if t[R] >= TRight - K:
                count += 1
                R -= 1
            else:
                break
print(answer)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

ps = defaultdict(int)
for i in range(N):
    T = int(input())
    ps[T] += 1

count = 0
current_ps = 0
time_limit = 10**9+K+1

for t in sorted(ps.keys()):
    if t > time_limit and current_ps > 0:
        count += 1
        current_ps = 0

    if current_ps == 0:
        time_limit = t + K

    current_ps += ps[t]
    while current_ps >= C:
        count += 1
        current_ps -= C
        time_limit = t + K

if current_ps > 0:
    count += 1

print(count)

Submission status: Accepted

Solution code:
from math import ceil

def main():
    N, C, K =list(map(int, input().split()))
    Ts = []
    for _ in range(N):
        Ts.append(int(input()))

    Ts.sort()

    bus_ct = 0
    in_bus = 1
    st = Ts.pop(0) + K
    for Ti in Ts:
        if Ti > st:
            bus_ct += 1
            in_bus = 1
            st = Ti + K
        elif Ti <= st:
            in_bus += 1

        if in_bus > C:
            bus_ct += 1
            in_bus = 1
            st = Ti + K
    
    if in_bus:
        bus_ct += 1
    
    print(bus_ct)

main()

Submission status: Accepted

Solution code:
N, C, K = map(int,input().split())
T = []
for _ in range(N):
  T.append(int(input()))
T.sort()
cnt=1
s=0
for i in range(1,N):
  if (T[i] > T[s]+K) or (i==s+C):
    cnt += 1
    s=i
print(cnt)

Submission status: Accepted

Solution code:
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()
s = 0
e = T[0]+K
p = 0
ans = 0
for i in range(N):
    if p == C or e < T[i]:
        ans += 1
        s = T[i]
        e = T[i]+K
        p = 0
    s = max(s,T[i])
    e = min(e,T[i]+K)
    p += 1
print(ans+1)

Submission status: Accepted

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

Submission status: Accepted

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

result = 1
count = 0
f = 0

for i in range(n):
  if (t[i] - t[f]) > k or c == count:
    result += 1
    count = 1
    f = i
  else:
    count += 1
print(result)

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
limit = T[0]
answer = 1
counter = 1
for i in range(1,N):
    if T[i] - limit > K or counter == C:
        limit = T[i]
        counter = 1
        answer += 1
    else:
        counter += 1
print(answer)

Submission status: Accepted

Solution code:
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
answer = 0
while len(T) > 0:
    limit = T[0] + K
    counter = 0
    while counter < C:
        if len(T) == 0:
            break
        if T[0] > limit:
            break
        del T[0]
        counter += 1
    answer += 1
print(answer)

Submission status: Accepted

Solution code:
n,c,k=[int(i) for i in input().split()]
people=list(reversed(sorted([int(input()) for _ in range(n)])))
start=people[0]
cnt=1
ans=1
for i in people[1:]:
    if start-i<=k and i>=start-k and cnt<c:
        cnt+=1
    else:
        cnt=1
        ans+=1
        start=i
print(ans)

Submission status: Accepted

Solution code:
n, c, k = map(int, input().split())
s = [int(input()) for _ in range(n)]
s = sorted(s)
num = 0
i = s[0]
m = s[0] + k
p = 1
for j in s[1:]:
    if j <= m and p < c:
        p += 1
    else:
        p = 1
        num += 1
        m = j + k
    i = j
num += 1
print(num)

Submission status: Accepted

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

bus_count = 1
bus_rider_count = 0
min_T = sTn[0]
for T in sTn:
    if bus_rider_count < C and min_T + K >= T:
        bus_rider_count += 1
    else:
        bus_count += 1
        bus_rider_count = 1
        min_T = T

print(bus_count)

Submission status: Accepted

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

time=T[0]
count = 1
ans = 0

for i in range(1,N):
  if T[i]-time>K or count==C:
    time = T[i]
    count = 1
    ans += 1
  else:
    count += 1
if count>0:
  ans += 1
print(ans)

Submission status: Accepted

Solution code:

N,C,K=map(int, input().split())
l = []
ans = 0
for i in range(N):
    l.append(int(input()))
l.sort()
l.append(float("INF"))
l = l[::-1]
while len(l)>1:
  h=l.pop()
  i=h
  j=1
  while len(l)>1 and j<C and h+K>=l[-1]:
    i=l.pop()
    j+=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()

ans = 0
i = 0
while i < n:
    cnt = 0
    a = t[i]+k
    for j in range(c):
        if i+j < n:
            if t[i+j] <= a:
                cnt += 1
            else:
                break
        else:
            break
    ans += 1
    i += cnt
print(ans)