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: Runtime Error

Solution code:
bus = 1
time = 0
for i in range(N):
    if T[i]-time > K:
        bus +=1
        time = T[i]
    else:
        time = time
print(bus)

Submission status: Runtime Error

Solution code:
N,C,K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
ans=s=0
while s<N:
    t=T[s]+K
    sm=1
    for i in range(s+1,s+c):
        if T[i]<t:
            sm+=1
        else:
            break
    s+=sm
    ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
import bisect

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

if T[0]+K>=T[-1]:
  print(1)
else:
  while True:
    if i==N-1:
      ans+=1
      break
    i=bisect.bisect_right(T,T[i]+K)
    print(T,i)
    ans+=1
  print(ans)

Submission status: Runtime Error

Solution code:
import bisect

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

if T[0]+K>=T[-1]:
  print(1)
else:
  while True:
    if i==N-1:
      ans+=1
      break
    i=bisect.bisect_left(T,T[i]+K)
    ans+=1
  print(ans)

Submission status: Runtime Error

Solution code:
def resolve():
    '''
    code here
    '''
    N, C, K = [int(item) for item in input().split()]
    Ts = [int(input()) for _ in range(N)]
    Ts.sort()

    res = 0
    temp_psg = 0
    lim = Ts[0] + K

    for i in range(N):
        temp_psg += 1
        if Ts[i] > lim:
            res += 1
            temp_psg = 1
            lim = Ts[i] + K
        else:
            if temp_psg == C:
                res += 1
                temp_psg = 0
                lim = Ts[i+1] + K
        # print(Ts[i], temp_psg, res, lim)
    
    if temp_psg > 0:
        res += 1
    print(res)


if __name__ == "__main__":
    resolve()

Submission status: Runtime Error

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())))
 
ans = -1
for i in range(n-1):
    if a[i]*2 < a[i+1]:
        ans = i
    a[i+1] += a[i]
print(n-ans-1)

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
ans = 1
num = sum(l)
for i in range(0,n-1):
    num -= l[i]
    if num*2<l[i]:
        break
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys
N, C, K = map(int, input().split())
A = list(map(int, sys.stdin.readlines()))+[10**10]
A.sort()
a, c, t = 0, 1, a[0]+k
for i in A[1:]:
    if i <= t and c < C:
        c += 1
    else:
        t, c = i + K, 1
        a += 1
 
print(a)

Submission status: Runtime Error

Solution code:
import bisect
kyaku, teiin, jikan = map(int, input().split(" "))
a=sorted([(int)(input()) for i in range(kyaku)])
print(a)
count = 0
while(True):
  print(a)
  if len(a) > teiin:
    if a[0] + jikan >= a[teiin]:
      a = a[teiin:]
    else:
      a = a[bisect.bisect_left(a, a[0] + jikan):]
  else:
    if a[0] + jikan >= a[-1]:
      count += 1
      break
    else:
      a = a[bisect.bisect_left(a, a[0] + jikan):]
  count += 1
print(count)

Submission status: Runtime Error

Solution code:
def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    ans = 0
    i = 0
    j = 0
    T.sort()
    if len(T) == 1:
        ans = 1
        return(ans)

    if C == 1:
        return(N)

    if C == 2:
        while True:
            if T[j] + K >= T[i+1]:
                i = i + 2
                j = i
                ans += 1
                if j == N:
                    return ans
                elif j == N - 1:
                    ans += 1
                    return ans
            elif T[j] + K < T[i+1]:
                i += 1
                j = i
                ans += 1
                if j == N-1:
                    ans += 1
                    return ans

    while True:
        if T[j] + K >= T[i+1]:
            i = i + 1
            if i == N-1:
                ans += 1
                return (ans)
            for h in range(C-2):
                if T[j] + K >= T[i+1]:
                    if h == C-3:
                        ans += 1
                        i += 2
                        j = i
                        if j == N-1:
                            ans += 1
                            return(ans)
                        elif j == N:
                            return(ans)
                        break
                    else:
                        i += 1
                        if (i+1) == N-1:
                            ans += 1
                            return(ans)
                        continue
                elif T[j] + K < T[i + 1]:
                    j = i + 1
                    i = i + 1
                    ans += 1
                    if j == N-1:
                        ans += 1
                        return(ans)
                    break

        elif T[j] + K < T[i+1]:
            ans += 1
            i += 1
            j = i
            if j == N-1:
                ans += 1
                return(ans)

print(main())

Submission status: Runtime Error

Solution code:
def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    ans = 0
    i = 0
    j = 0
    T.sort()
    if len(T) == 1:
        ans = 1
        return(ans)

    if C == 1:
        return(N)

    if C == 2:
        while True:
            if T[j] + K >= T[i+1]:
                i = i + 2
                j = i
                ans += 1
                if j == N:
                    return ans
                elif j == N - 1:
                    ans += 1
                    return ans
            elif T[j] + K < T[i+1]:
                i += 1
                j = i
                ans += 1
                if j == N-1:
                    ans += 1
                    return ans

    while True:
        if T[j] + K >= T[i+1]:
            i = i + 1
            if i == N-1:
                ans += 1
                return (ans)
            for h in range(C-2):
                if T[j] + K >= T[i+1]:
                    if h == C-3:
                        ans += 1
                        i += 2
                        j = i
                        if j >= N-1:
                            return(ans)
                        break
                    else:
                        i += 1
                        if (i+1) == N-1:
                            ans += 1
                            return(ans)
                        continue
                elif T[j] + K < T[i + 1]:
                    j = i + 1
                    i = i + 1
                    ans += 1
                    if j == N-1:
                        ans += 1
                        return(ans)
                    break

        elif T[j] + K < T[i+1]:
            ans += 1
            i += 1
            j = i
            if j == N-1:
                ans += 1
                return(ans)

print(main())

Submission status: Runtime Error

Solution code:
def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    ans = 0
    i = 0
    j = 0
    T.sort()
    if len(T) == 1:
        ans = 1
        return(ans)

    if C == 1:
        return(N)

    if C == 2:
        while True:
            if T[j] + K >= T[i+1]:
                i = i + 2
                j = i
                ans += 1
                if j == N + 1:
                    return ans
                elif j == N:
                    ans += 1
                    return ans
            elif T[j] + K < T[i+1]:
                i += 1
                j = i
                ans += 1
                if j == N-1:
                    ans += 1
                    return ans



    while True:
        if T[j] + K >= T[i+1]:
            i = i + 1
            if i == N-1:
                ans += 1
                return (ans)
            for h in range(C-2):
                if T[j] + K >= T[i+1]:
                    if h == C-3:
                        ans += 1
                        i += 2
                        j = i
                        if j >= N-1:
                            return(ans)
                        break
                    else:
                        i += 1
                        if (i+1) == N-1:
                            ans += 1
                            return(ans)
                        continue
                elif T[j] + K < T[i + 1]:
                    j = i + 1
                    i = i + 1
                    ans += 1
                    if j == N-1:
                        ans += 1
                        return(ans)
                    break

        elif T[j] + K < T[i+1]:
            ans += 1
            i += 1
            j = i
            if j == N-1:
                ans += 1
                return(ans)

print(main())

Submission status: Runtime Error

Solution code:
def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    ans = 0
    i = 0
    j = 0
    T.sort()
    if len(T) == 1:
        ans = 1
        return(ans)

    while True:
        if T[j] + K >= T[i+1]:
            i = i + 1
            if i == N-1:
                ans += 1
                return (ans)
            for h in range(C-2):
                if T[j] + K >= T[i+1]:
                    if h == C-3:
                        ans += 1
                        i += 2
                        j = i
                        if j >= N-1:
                            return(ans)
                        break
                    else:
                        i += 1
                        if (i+1) == N-1:
                            ans += 1
                            return(ans)  
                        continue
                elif T[j] + K < T[i + 1]:
                    j = i + 1
                    i = i + 1
                    ans += 1
                    if j == N-1:
                        ans += 1
                        return(ans)
                    break

        elif T[j] + K < T[i+1]:
            ans += 1
            i += 1
            j = i
            if j == N-1:
                ans += 1
                return(ans)

print(main())

Submission status: Runtime Error

Solution code:
def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    ans = 0
    i = 0
    j = 0
    T.sort()
    if len(T) == 1:
        ans = 1
        return(ans)

    while True:
        if T[j] + K >= T[i+1]:
            i = i + 1
            if i == N-1:
                ans += 1
                return (ans)
            for h in range(C-2):
                if T[j] + K >= T[i+1]:
                    if h == C-3:
                        ans += 1
                        i += 2
                        j = i
                        if j >= N-1:
                            return(ans)
                        break
                    else:
                        i += 1
                        if (i+1) == N-1:
                            ans += 1
                            return(ans)  
                        continue
                elif T[j] + K < T[i + 1]:
                    j = i + 1
                    i = i + 1
                    ans += 1
                    if j == N-1:
                        ans += 1
                        return(ans)
                    break

        elif T[j] + K < T[i+1]:
            ans += 1
            i += 1
            j = i
            if j == N-1:
                ans += 1
                return(ans)

print(main())

Submission status: Runtime Error

Solution code:
def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    ans = 0
    i = 0
    j = 0
    T.sort()
    if len(T) == 1:
        ans = 1
        return(ans)

    while True:
        if T[j] + K >= T[i+1]:
            i = i + 1
            if i == N-1:
                ans += 1
                return (ans)
            for h in range(C-2):
                if T[j] + K >= T[i+1]:
                    if h == C-3:
                        ans += 1
                        i += 2
                        j = i
                        if j >= N-1:
                            return(ans)
                        break
                    else:
                        i += 1
                        continue
                elif T[j] + K < T[i + 1]:
                    j = i + 1
                    i = i + 1
                    ans += 1
                    if j == N-1:
                        ans += 1
                        return(ans)
                    break

        elif T[j] + K < T[i+1]:
            ans += 1
            i += 1
            j = i
            if j == N-1:
                ans += 1
                return(ans)

print(main())

Submission status: Runtime Error

Solution code:
def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    ans = 0
    i = 0
    j = 0
    T.sort()
    if len(T) == 1:
        ans = 1
        return(ans)

    while True:
        if T[j] + K >= T[i+1]:
            i = i + 1
            if i == N-1:
                ans += 1
                return (ans)
            for h in range(C-2):
                if T[j] + K >= T[i+1]:
                    if h == C-3:
                        ans += 1
                        i += 2
                        j = i
                        if j >= N-1:
                            return(ans)
                        break
                    else:
                        i += 1
                        continue
                elif T[j] + K < T[i + 1]:
                    j = i + 1
                    i = i + 1
                    ans = 1
                    break

        elif T[j] + K < T[i+1]:
            ans += 1
            i += 1
            j = i
            if j == N-1:
                ans += 1
                return(ans)

print(main())

Submission status: Runtime Error

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

    while True:
        if T[j] + K >= T[i+1]:
            i = i + 1
            if i == N-1:
                ans += 1
                return (ans)
            for h in range(C-2):
                if T[j] + K >= T[i+1]:
                    if h == C-3:
                        ans += 1
                        i += 2
                        j = i
                        if j >= N-1:
                            return(ans)
                        break
                    else:
                        i += 1
                        continue
                elif T[j] + K < T[i + 1]:
                    j = i + 1
                    i = i + 1
                    ans = 1
                    break

        elif T[j] + K < T[i+1]:
            ans += 1
            i += 1
            j = i
            if j == N-1:
                ans += 1
                return(ans)

print(main())

Submission status: Runtime Error

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

    while True:
        if T[j] + K >= T[i+1]:
            i = i + 1
            if i == N-1:
                ans += 1
                return (ans)
            for h in range(C-2):
                if T[j] + K >= T[i+1]:
                    if h == C-3:
                        ans += 1
                        i += 2
                        j = i
                        if j >= N-1:
                            return(ans)
                        break
                    else:
                        i += 1
                        continue
                elif T[j] + K < T[i + 1]:
                    j = i + 1
                    i = i + 1
                    ans = 1
                    break

        elif T[j] + K < T[i+1]:
            ans += 1
            i += 1
            j = i
            if j == N-1:
                ans += 1
                return(ans)

print(main())

Submission status: Runtime Error

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

check = [0] * (n+10)

for i in range(n):
    check[int(input())] += 1

wait = False
time_cnt = 0
people_cnt = 0
ans = 0

for i in range(len(check)):
    if wait == False:
        if check[i] > 0:
            wait = True
            people_cnt += check[i]
            time_cnt = 1
            continue
        else:
            continue
        
    if people_cnt > c:
        ans += people_cnt//c
        people_cnt = people_cnt%c
        time_cnt = 1
        
    
    if time_cnt > k:
        ans += 1
        people_cnt = 0
        time_cnt = 0
        wait = False
    
    people_cnt += check[i]
    time_cnt += 1
else:
    if people_cnt > 0:
        ans += people_cnt//c
    if people_cnt%c > 0:
        ans += 1

print(ans)

Submission status: Runtime Error

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

check = [0] * (n+10)

for i in t:
    check[i] += 1

wait = False
time_cnt = 0
people_cnt = 0
ans = 0

for i in range(len(check)):
    if wait == False:
        if check[i] > 0:
            wait = True
            people_cnt += check[i]
            time_cnt = 1
            continue
        else:
            continue
        
    if people_cnt > c:
        ans += people_cnt//c
        people_cnt = people_cnt%c
        time_cnt = 1
        
    
    if time_cnt > k:
        ans += 1
        people_cnt = 0
        time_cnt = 0
        wait = False
    
    people_cnt += check[i]
    time_cnt += 1
else:
    if people_cnt > 0:
        ans += people_cnt//c
    if people_cnt%c > 0:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
from collections import deque

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

T_list = list() #左がもっとも早く着いた人

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

T_list.sort(reverse=False)

waiting_deque = deque(T_list)
ans = 0

while 1:
    if len(waiting_deque) != 0:
        ans += 1
        bus_passenger = list()
        bus_passenger.append(waiting_deque.popleft())
        while 1:
            if len(waiting_deque)!=0 and len(bus_passenger) < C and bus_passenger[0] + K => waiting_deque[0]:
                bus_passenger.append(waiting_deque.popleft())
            else:
                #print(bus_passenger)
                break
    else:
        break

print(ans)

Submission status: Runtime Error

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

bus = 0
idx = 0
while idx < N:
    bus_go = t[idx] + K
    tmp = 0
    while idx < N:
        if t[idx] <= bus_go:
            tmp += 1
            idx += 1
            if tmp == C:
                bus += 1
                bus_go = t[idx] + K
                tmp = 0
        else:
            break

    if tmp > 0:
        bus += 1

print(bus)

Submission status: Runtime Error

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


sort(t)
ans = 0
now = 0
ter = -1
for i in range(n):
  if ter < t[i]+k:
    ans+=1
    ter = t[i]+k
    now = 1
  else:
    if(c>=now):
      ans+=1
      ter = t[i]+k
      now = 1
    else:
      now += 1
      
print(ans)

Submission status: Runtime Error

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

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

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

while len(t_list) > 0:
    _tmp = t_list.popleft() + k
    _idx = bisect.bisect_right(t_list, _tmp)
    if c <= _idx + 1:
        for _ in range(c):
            t_list.popleft()
    else:
        for _ in range(_idx):
            t_list.popleft()
    ans += 1

print(ans)

Submission status: Runtime Error

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

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

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

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

Submission status: Runtime Error

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

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

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

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

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

print(ans)

Submission status: Runtime Error

Solution code:
from math import ceil
 
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
 
T.sort()
 
bus = 0
bus_time = T[0] + K
tmp_bus = 1
 
for i in range(1,N):
    if T[i] > bus_time:
        bus += 1
        bus_time = T[i+1] + K
        tmp_bus = 0
    else:
        tmp_bus += 1
    
    if tmp_bus == C:
        bus += 1
        bus_time = T[i+1] + K
        tmp_bus = 0
 
print(bus+1)

Submission status: Runtime Error

Solution code:
N,C,K = map(int,input().split())
A = []
for _ in range(N):
  A.append(int(input()))
A.sort()
A0 = A[0]
lis = []
cnt = 0
for i,name enumerate(A):
  if name <= A0 + K and len(lis) < C:
    lis.append(name)
    if len(lis) == C or i ==  N:
      lis.clear()
      cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
input = sys.stdin.readline
n,c,k = map(int,input().split())
A = [int(input()) for i in range(n)]
a = sorted(A)
ans = 0
time = 0.1 
num = 0
for i in range(n):
    if ans == 0:
        ans +=1
        time = a[0] -0.1
        num +=1
    elif ans != 0 and a[i] < time +k and num < c :
        num +=1
    elif  ans != 0 and (c <=num  or  time +k <=a[i]):
      
        time = a[i] -0.1
        num = 1
        ans +=1
print(ans)

Submission status: Runtime Error

Solution code:
from collections import deque
n,c,k = map(int,input().split())
t = []
for _ in range(n):
    tt = int(input())
    t.append(tt)
t.sort()
ans = deque([])
cnt = 0
for i, tt in enumerate(t):
    if i == 0:
        ans.append([tt+k,1])
        cnt += 1
    else:
        flg = False
        for i in range(len(ans)):
            tmp = ans.popleft()
            if tmp[0] < tt or tmp[1] == c:

                continue
            else:
                flg = True
                break
        if flg :
            tmp[1] += 1
            if tmp[1] != c:
                a.append(tmp)
                ans.appendleft(tmp)
        else:
            tmp = [tt+k,1]
            ans.append(tmp)
            cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
N,C,K = map(int, input().split())
T = []
for i in range(N):
  S.append(input())
S.sort()
st = 0
fi = 1
count = 0
for i in range(N):
  a = S[i]
  if S[i] == 

while S[fi]-S[st] <= K and fi-st-1 <= C:
  fi += 1
else:
  count += 1
  st = fi + 1
  fi = fi + 1
print(count)



N,C,K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
st = 0
fi = 1
count = 0
while S[fi]-S[st] <= K and int(fi)-int(st)-1 <= C:
  fi += 1
else:
  count += 1
  st = fi + 1
  fi = fi + 1
print(count)

Submission status: Runtime Error

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

bus = 1
bustime = ab[0] + k
customer = 1

for i in range(1,n):
    if ab[i] <= bustime:
        customer += 1
        if customer == c:
            bustime = ab[i+i]+k
            customer = 0
            bus += 1
    elif bustime < ab[i]:
        bustime = ab[i]+k
        customer = 1
        bus += 1
print(bus)

Submission status: Runtime Error

Solution code:
import copy

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

t.sort()
s = copy.copy(t)
ans = 0
for i in range(n):
  cnt = 1
  for j in range(i+1, n):
    if t[j] - t[i] <= k:
      cnt += 1
      t.remove(t[j])
      if cnt == c:
        ans += 1
        break
    else:
      ans += 1
      break
      
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))

tmp = 0
sum_a = sum(A)
ind = N+1
for i in range(N-1):
    #tmp += A[i]*2
    tmp = 2*sum(A[:i+1])
    if tmp < A[i+1]:
        ind = i

if ind == N+1:
    print(N)
else:
    print(N-ind-1)

Submission status: Runtime Error

Solution code:
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]+[10**9]
t.sort()
b=1
p=0
while p<n:
  l=t[p]+k
  pp=1
  f=1
  while pp<c and f:
    p+=1
    if t[p]<=l:
      pp+=1
      if pp==c:
        p+=1
    else:
      f=0
  if p<n:
    b+=1
print(b)

Submission status: Runtime Error

Solution code:
T = [int(input()) for _ in range(N)]
T.sort()

def init_bus():
    global bus, min_t, ans
    bus = []
    bus.append(t)
    min_t = t
    ans += 1

min_t = 0
for t in T:
    if len(bus) == 0:
        init_bus()
        continue
    if t - min_t < K and len(bus) < C:
        bus.append(t)
    else:
        init_bus()
print(ans)

Submission status: Runtime Error

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
jk = 0
t = T[0]
for i in range(n):
    if T[i]-t>k:
        ans += 1
        jk = 0
        t = T[i]
        continue
    jk += 1
    if jk==c:
        ans += 1
        jk = 0
        t = T[i]
print(ans if jk== else ans+1)

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
n,c,k=map(int,input().split())
t=[int(input()) for i in range(n)]
t=sorted(t)
ans=0
cnt=0
first_time=t[0]
for i in range(n):
    time=t[i]-first_time
    cnt+=1
    if time==0:
        if i<=n-2 and t[i+1]-first_time>k:
            ans+=1
            first_time=t[i+1]
            cnt=0
        elif cnt==c:
            ans+=1
            first_time=t[i+1]
            cnt=0

    elif time>k:
        ans+=1
        first_time=t[i]
        cnt=0
    elif cnt==c:
        ans+=1
        first_time=t[i+1]
        cnt=0

    if i==n-1 and cnt!=0:
        ans+=1

print(ans)

Submission status: Runtime Error

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

count = 0
ans = 0

newLi = sorted(li)

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

  newLi.pop(0)
  ans += 1

print(ans)

Submission status: Runtime Error

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

listT.sort()

def func(listT,bus):
    if len(listT)<2:
            print(bus+1)
            sys.exit()

    elif len(listT)>=2:
        for i in range(1,max(C,len(listT))):

            if listT[i]-listT[0]>K:
                bus += 1
                return func(listT[i:],bus)

        bus += 1

        if len(listT)<C:
            print(bus)
            sys.exit()


        return func(listT[C:],bus)

func(listT,0)

Submission status: Runtime Error

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: Runtime Error

Solution code:
N, C, K = [int(i) for i in input().split()]
T = list(sorted([int(i) for i in input().split()]))
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: Runtime Error

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: Runtime Error

Solution code:




def main()->None:
    N, C, K = map(int, input().split())
    range_N = range(N)
    T = [int(i) 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: Runtime Error

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


def AirportBus(x=0, y=0):
    if x == n:
        return    
    y = min(bisect.bisect(t, t[x]+k), x+3)
    l.append(t[x:y])
    AirportBus(y)
    
l = []    
AirportBus()

print(len(l))