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: Wrong Answer

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

def main():
    N, C, K = map(int, input().split())
    times = sorted([int(input()) for _ in range(N)])
    idx = 0
    base_time = times[idx]
    passenger_num = 1
    ans = 0
    while True:
        idx += 1
        if idx == len(times):
            if passenger_num > 0:
                ans += 1
            break
        if passenger_num == 0:
            base_time = times[idx]
        if times[idx] - base_time < K:
            passenger_num += 1
            if passenger_num == C:
                ans += 1
                passenger_num = 0
        elif times[idx] - base_time >= K:
            base_time = times[idx]
            ans += 1
            passenger_num = 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    N, C, K = map(int, input().split())
    times = sorted([int(input()) for _ in range(N)])
    idx = 0
    base_time = times[idx]
    passenger_num = 1
    ans = 0
    while True:
        idx += 1
        if passenger_num == 0:
            base_time = times[idx]
        if idx == len(times):
            if passenger_num > 0:
                ans += 1
            break
        if times[idx] - base_time < K:
            passenger_num += 1
            if passenger_num == C:
                ans += 1
                passenger_num = 0
        elif times[idx] - base_time >= K:
            base_time = times[idx]
            ans += 1
            passenger_num = 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    N, C, K = map(int, input().split())
    times = sorted([int(input()) for _ in range(N)])
    idx = 0
    base_time = times[idx]
    passenger_num = 1
    ans = 0
    while True:
        idx += 1
        if idx == len(times):
            if passenger_num > 0:
                ans += 1
            break
        if times[idx] - base_time < K:
            passenger_num += 1
            if passenger_num == C:
                ans += 1
                passenger_num = 0
        elif times[idx] - base_time >= K:
            base_time = times[idx]
            ans += 1
            if idx + 1 != len(times):
              passenger_num = 1
            else:
              passenger_num = 0
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    N, C, K = map(int, input().split())
    times = sorted([int(input()) for _ in range(N)])
    idx = 0
    base_time = times[idx]
    passenger_num = 0
    ans = 0
    while True:
        idx += 1
        if passenger_num == 0:
            passenger_num += 1
        if idx == len(times):
            if passenger_num != 1:
                ans += 1
            break
        if times[idx] - base_time < K:
            passenger_num += 1
            if passenger_num == C:
                ans += 1
                passenger_num = 0
        elif times[idx] - base_time >= K:
            base_time = times[idx]
            ans += 1
            passenger_num = 0
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import deque

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

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

T = sorted(T)
con = 0
bus = deque()

for i in range(N):
  t = T[i]
  #バスに乗れるなら乗せる
  ##乗客が0人の時は問答無用で乗れる
  ##乗客がいる場合、最初の乗客が乗った時間から経過時間がK未満
  ##なおかつ、乗客がC人未満なら乗れる
  if len(bus) == 0 or (t - bus[0] < K and len(bus) < C):
    bus.append(t)
  else:
    bus = deque()
    con += 1
    bus.append(t)
    
if len(bus) > 0:
  con += 1
  
print(con)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

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

T = sorted(T)
con = 0
bus = deque()

for i in range(N):
  t = T[i]
  #バスに乗れるなら乗せる
  ##乗客が0人の時は問答無用で乗れる
  ##乗客がいる場合、最初の乗客が乗った時間から経過時間がK未満
  ##なおかつ、乗客がC人未満なら乗れる
  if len(bus) == 0 or (t - bus[0] < K and len(bus) < C):
    bus.append(t)
  else:
    bus = deque()
    con += 1
    bus.append(t)
  
print(con + 1)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

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

T = sorted(T)
con = 0
bus = deque()

for i in range(N):
  t = T[i]
  if len(bus) == 0 or (t - bus[-1] < K and len(bus) < C):
    bus.append(t)
  else:
    bus = deque()
    con += 1
    bus.append(t)
  
print(con + 1)

Submission status: Wrong Answer

Solution code:
N,C,K=map(int,input().split(' '))
T=sorted([int(input()) for i in range(N)])
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: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
tList = [int(input()) for _ in range(n)]
tList.sort()
ans = []
while 1:
    limit = tList[0] + k
    for i in range(min(c, len(tList))):
        mark = i
        if tList[i] > limit:
            break
    ans.append(tList[:mark + 1])
    tList = tList[mark + 1:]
    if tList == []:
        break
print(len(ans))

Submission status: Wrong Answer

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

def solve(i):
    global N, C, K, T
    left = C - 1
    # 最後
    if i == N - 1:
        return i
    for j in range(i + 1, N):
        # print(T[i], i, j)
        if T[i] + K < T[j]:
            return j - 1
        else:
            left -= 1
        if left == 0 or j == N - 1:
            return j

buses = 0
start = -1
for i in range(N):
    if start < i:
        start = solve(i)
        buses += 1

print(buses)

Submission status: Wrong Answer

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

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

def solve(i):
    global N, C, K, T
    left = C - 1
    # 最後
    if i == N - 1:
        return i
    for j in range(i + 1, N):
        # print(T[i], i, j)
        if T[i] + K < T[j]:
            return j - 1
        else:
            left -= 1
        if left == 0 or j == N - 1:
            return j

buses = 0
ride_i = None
for i in range(N):
    if ride_i is None or (ride_i is not None and ride_i < i):
        ride_i = solve(i)
        # print(i, ride_i)
        buses += 1

print(buses)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

T.sort()

busses = 0

isRemained = True
while isRemained:
    busses += 1
    human = 1
    first_arrival = T[0]
    while human <= C and human <= len(T):
        if T[human-1]-T[0] <= K:
            human += 1
        else:
            break
    T = T[human:]
    if len(T) == 0:
        busses += 1
        isRemained = False

print(busses)

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
 
T = []
for _ in range(N):
    T.append(int(input()))
T.sort()
 
buses = 0
current_bus = 0
anger_time = None
 
for i in range(N):
    current_bus += 1
    if anger_time is None:
        anger_time = T[i] + K
 
    if current_bus >= C:
        buses += 1
        current_bus = 0
        anger_time = None
        next
 
    if i < N - 1 and anger_time is not None and anger_time < T[i + 1]:
        buses += 1
        current_bus = 0
        anger_time = None
        next
    
    if i == N - 1:
        buses += 1
        current_bus = 0
        anger_time = None
 
print(buses)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

T.sort()

busses = 0

isRemained = True
while isRemained:
    busses += 1
    i = 1
    first_arrival = T[0]
    while True:
        if i <= C and i <= len(T):
            if T[i-1]-T[0] <= K:
                i += 1
        else:
            break
    T = T[i:]
    if len(T) == 0:
        busses += 1
        isRemained = False

print(busses)

Submission status: Wrong Answer

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

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

buses = 0
current_bus = 0
anger_time = None

for i in range(N):
    current_bus += 1
    if anger_time is None:
        anger_time = T[i] + K

    if current_bus >= C:
        buses += 1
        current_bus = 0
        anger_time = None
        next

    if i < N - 1 and anger_time is not None and anger_time < T[i + 1]:
        buses += 1
        current_bus = 0
        anger_time = None
        next
    
    if i == N - 1:
        buses += 1
        current_bus = 0
        anger_time = None

print(buses)

Submission status: Wrong Answer

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

bus = 1
st = T_lst[0]
num = 1
for i in range(1, N):
    if T_lst[i] <= st + K and num < C:
        num += 1
        continue
    else:
        st = T_lst[i]
        bus += 1
        num = 0
print(bus)

Submission status: Wrong Answer

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

bus = 1
st = T_lst[0]
num = 1
for i in range(1, N):
    if T_lst[i] <= st + K and num <= C:
        num += 1
        continue
    else:
        st = T_lst[i]
        bus += 1
        num = 0
print(bus)

Submission status: Wrong Answer

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

bus = 1
st = T_lst[0]
for i in range(1, N):
    if T_lst[i] <= st + C:
        continue
    else:
        st = T_lst[i]
        bus += 1
print(bus)

Submission status: Wrong Answer

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

ans = 1
bus = C
time = T[0] + K
for i in T:
    # バスの定員に空きがあり、かつ、乗車1人目の許容時間内の場合同じバスに乗る
    if (bus > 0) & (i < time):
        bus -= 1
    # バスが定員、または、乗車1人目の許容時間外の場合新しいバスに乗る
    else:
        bus = C - 1
        time = i + K
        ans += 1

print(ans)

Submission status: Wrong Answer

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

ans = 1
bus = C
time = K
for i in T:
    # 1人目
    if bus == C:
        bus -= 1
        time = i + K
    # 2人目以降
    else:
        # バスが定員未満、かつ、乗車1人目が許容できる時間内の場合は同じバスに乗る
        if (bus > 0) & (i < time):
            bus -= 1
        # バスが定員、または、乗車1人目の許容時間外の場合新しいバスに乗る
        else:
            bus = C - 1
            time = i + K
            ans += 1

print(ans)

Submission status: Wrong Answer

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

T.sort()

#%%
cnt = 0
ans = 1
time = T[0]
for i in range(N):
    if cnt == 0:
        time = T[i]

    if time <= T[i] <= time + K:
        cnt += 1
    else:
        ans += 1
        cnt = 0

    if cnt == C:
        ans += 1
        cnt = 0

if cnt == 1:
    ans += 1
print(ans)

Submission status: Wrong Answer

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

T.sort()

cnt = 0
ans = 1
for t in T:
    if cnt == 0:
        time = t

    if time <= t < time + K and cnt < C:
        cnt += 1
        if cnt == C:
            ans += 1
            cnt = 0
    else:
        ans += 1
        cnt = 0

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N, C, K = Scanner.map_int()
    T = Scanner.int_cols_list(N)
    T.sort()
    S = [x + K for x in T]
    ans = 0
    cnt = 0
    lim = 0
    for i in range(N):
        if cnt == 0:
            lim = T[i] + K
        elif lim < T[i]:
            ans += 1
            lim = T[i] + K
        cnt += 1
        if cnt == C:
            ans += 1
            cnt = 0
            lim = 0
    if lim > 0:
        ans += 1
    print(ans)
    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
t=[int(input()) for i in range(n)]
t=sorted(t)+[10**5]
ans=0
cnt=0
f_cl=t[0]
for i in range(n+1):
    time=t[i]-f_cl
    cnt+=1
    if i==n-1:
        ans+=1

    elif cnt==c and time<=k:
        ans+=1
        f_cl=t[i+1]
        cnt=0

    elif time>k and i!=n:
        ans+=1
        f_cl=t[i]

print(ans)

Submission status: Wrong Answer

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

print(T)
count_bus = 0

i = 0
while i < len(T):
    print('T[{}]: {}'.format(i, T[i]))
    t = T[i]
    for j in range(1, C):
        if i+j >= len(T):
            i += j
            count_bus += 1
            break

        if T[i+j] <= t + K:
            pass
            if j == C-1:
                i += j + 1
                count_bus += 1
                break

        else:
            count_bus += 1
            i += j
            break

print(count_bus)

Submission status: Wrong Answer

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

passengers = sorted(T)
print('-', passengers)

def in_k(_passengers):
    in_k_list = [t for t in _passengers if t <= _passengers[0]+K]
    in_k_count = len(in_k_list)
    if in_k_count > C:
        remaining = _passengers[C:]
    else:
        remaining = _passengers[in_k_count:]
    return in_k_list, remaining


count_bus = 0
while len(passengers):
    in_k_list, passengers = in_k(passengers)
    count_bus += 1
    print(passengers)

print(count_bus)

Submission status: Wrong Answer

Solution code:
N, C, K = map(int,input().split())
T = [int(input()) for i in range(N)]
# print(T)
T.sort()
# print(T)
time = T[0]
people = 0
bus = 1
for i in T:
    people += 1 #乗客を乗せようとする
    if i - time > K or people > K: #乗せられないとき
        bus += 1 
        time = i
        people = 1 #次のバスに客iを乗せる
print(bus)

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
buses = 0
# 残ってる乗客で最も早くに来た人のindex
oldest_passenger_i = None
# 残ってる乗客数
remaining_passengers = 0
hoge = {}
fuga = {}
times = set()
for _ in range(N):
    t = int(input())
    if t in hoge:
        hoge[t] += 1
    else:
        hoge[t] = 1
    times.add(t)
    times.add(t + K)
    if (t + K) in fuga:
        fuga[t + K] += 1
    else:
        fuga[t + K] = 1

times = list(times)
sorted(times)

for t in times:
    # 到着する乗客数
    passengers = 0
    if t in hoge:
        passengers = hoge[t]
    # 限界の乗客数
    limit_passengers = 0
    if t in fuga:
        limit_passengers = fuga[t]
    remaining_passengers += passengers
    # 限界を迎える乗客がいる場合
    if limit_passengers > 0 and remaining_passengers > 0:
        new_buses = (limit_passengers + C - 1) // C
        buses += new_buses
        remaining_passengers = max(0, remaining_passengers - (new_buses * C))
print(buses)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()
time = li[0]
people = 1
bus_num = 1

for i in li:
    if i-time > k or people > c:
        bus_num += 1
        time = i
        people = 1
        continue
    people += 1
print(bus_num)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()
time = li[0]
people = 1
bus_num = 1

for i in li:
    people += 1
    if i-time > k or people > c:
        bus_num += 1
        time = i
        people = 1
print(bus_num)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()
time = li[0]
people = 0
bus_num = 1

for i in li:
    people += 1
    if i-time > k or people > c:
        bus_num += 1
        time = i
        people = 0
print(bus_num)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()

time = li[0]
bus = 1
hito = 0
for i in li:
    hito += 1
    if i-time > k or hito > c:
        bus += 1
        hito = 0
        time = i
print(bus)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]+[10**10]
li.sort()

time = li[0]
bus = 0
hito = 0

for i in li:
    hito += 1
    if i-time > k or hito > c:
        bus += 1
        hito = 0
        time = i
print(bus)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()
bus = 1
time = li[0]
point = 1
for i in li:
    if i-time > k or point > c:
        time = i
        point = 1
        bus += 1
        continue
    point += 1
print(bus)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]+[10**10]
li.sort()
bus = 1
time = li[0]
point = 1
for i in li:
    if i-time > k or point > c:
        time = i
        point = 0
        bus += 1
        continue
    point += 1
print(bus)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]+[10**10]
li.sort()
bus = 0
time = li[0]
point = 0
for i in li:
    if i-time > k or point > c:
        time = i
        point = 0
        bus += 1
        continue
    point += 1
print(bus)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]+[10**10]
li.sort()
bus = 1
time = li[0]
point = 0
for i in li:
    if i-time > k or point > c:
        time = i
        point = 0
        bus += 1
        continue
    point += 1
print(bus)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]+[10**10]
li.sort()
bus = 0
time = li[0]
point = 0
for i in li:
    if i-time > c or point > c:
        bus += 1
        time = i
        point = 0
    point += 1
print(bus)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()

#出発するための最低限のバスの台数
num_bus = 1
#現在何人目か(0スタート)
now = 0
#初期時間
time = li[0]
#初期人数
people_num = 0

flag = 0

while True:
    if now == n:
        break
    if li[now]-time > k:
        flag = 1
        time = li[now]
    if people_num > c:
        flag = 1
        people_num = 0
        time = li[now]
    if flag == 1:
        flag = 0
        num_bus += 1
    now += 1
    people_num += 1

print(num_bus)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()

#出発するための最低限のバスの台数
num_bus = 1
#現在何人目か(0スタート)
now = 0
#初期時間
time = li[0]
#初期人数
people_num = 0

while True:
    if now == n:
        break
    if li[now]-time > k:
        num_bus += 1
        time = li[now]
    if people_num > c:
        num_bus += 1
        people_num = 0
        time = li[now]
    now += 1
    people_num += 1

print(num_bus)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()

#出発するための最低限のバスの台数
num_bus = 1
#現在何人目か(0スタート)
now = 0
#初期時間
time = li[0]
#初期人数
people_num = 1

while True:
    if now == n:
        break
    if li[now]-time > k:
        num_bus += 1
        time = li[now]
    if people_num > c:
        num_bus += 1
        people_num = 1
        time = li[now]
    now += 1
    people_num += 1

print(num_bus)

Submission status: Wrong Answer

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

# passengers = sorted([int(input()) for i in range(N)])
passengers = ([int(input()) for i in range(N)])
res = {}

for p in passengers:
    key = False
    for k in res.keys():
        if k <= p and p <= k + K and res[k] <= C - 1:
            res[k] += 1
            key = True
            break
    if not key:
        res[p] = 1
print(len(res))

Submission status: Wrong Answer

Solution code:
N,C,K = map(int,input().split())
T = []
for _ in range(N):
    t = int(input())
    T.append(t)
T.sort()
angry = 0
ans = 0
c = 0
for i in T:
    if angry == 0:
        angry = i + K
    c += 1
    if i >= angry :
        #print(i,angry)
        angry = i + K
        ans += 1
        c = 1
    if c == C:
        angry = 0
        ans += 1
        c = 0
    #print(ans,angry,c)
if c > 0:
    ans += 1
if C == 1:
    ans = N
print(ans)

Submission status: Wrong Answer

Solution code:
N,C,K = map(int,input().split())
T = []
for _ in range(N):
    t = int(input())
    T.append(t)
T.sort()
angry = 0
ans = 0
c = 0
for i in T:
    if angry == 0:
        angry = i + K
    c += 1
    if i >= angry :
        #print(i,angry)
        angry = i + K
        ans += 1
        c = 1
    if c == C:
        angry = 0
        ans += 1
        c = 0
    #print(ans,angry,c)
if c > 0:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N,C,K = map(int,input().split())
T = []
for _ in range(N):
    t = int(input())
    T.append(t)
T.sort()
angry = 0
ans = 0
c = 0
for i in T:
    if angry == 0:
        angry = i + K
    c += 1
    if i >= angry :
        #print(i,angry)
        angry = i + K
        ans += 1
        c = 1
    elif c == C:
        angry = 0
        ans += 1
        c = 0
    #print(ans,angry,c)
if c > 0:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

if C == 1:
	print(N)
	sys.exit()

cnt = 0
capacity = 0
time_limit = 0
for i in range(N):
	if capacity == 0:
		capacity += 1
		time_limit = T[i] + K
		continue
	if capacity > 0:
		if T[i] <= time_limit:
			capacity += 1
			if capacity == C:
				cnt += 1
				capacity = 0
				continue
		elif T[i] > time_limit:
			cnt += 1
			capacity = 1
			time_limit = T[i] + K


print(cnt+1)

Submission status: Wrong Answer

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) < c + 2:
      continue
    
    if newLi[1] <= newLi[0] + K:
      newLi.pop(1)
    else:
      break

  newLi.pop(0)
  ans += 1

print(ans)

Submission status: Wrong Answer

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) < c + 2:
      continue
    
    if newLi[c + 1] <= newLi[0] + K:
      newLi.pop(c + 1)

  newLi.pop(0)
  ans += 1

print(ans)

Submission status: Wrong Answer

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)):
  k = newLi[0]

  for c in range(C - 1):
    if len(newLi) < c + 2:
      continue
    
    if newLi[c + 1] <= k + K:
      newLi.pop(c + 1)

  newLi.pop(0)
  ans += 1

print(ans)

Submission status: Wrong Answer

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

count = 0
ans = 0

while(len(li)):
  k = li[0]

  for c in range(C - 1):
    if len(li) < c + 2:
      continue
    
    if li[c + 1] <= k + K:
      li.pop(c + 1)

  li.pop(0)
  ans += 1

print(ans)

Submission status: Wrong Answer

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

listT.sort()

def func(listT,bus):
    if len(listT)>=C:
        deadline = listT[0]+K
        for i in range(0,C):

            if deadline>= listT[i]:
                continue
            else:
                bus += 1

                return func(listT[i:],bus)


        bus += 1

        return func(listT[C:],bus)



    elif len(listT)<C:

        for i in range(1, len(listT)):
            if listT[i]-listT[i-1] > K:
                bus += 1
        print(bus+1)




func(listT,0)

Submission status: Wrong Answer

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

listT.sort()

def func(listT,bus):
    if len(listT)>=C:
        for i in range(0,C):
            deadline = listT[0]+K
            if deadline>= listT[i]:
                continue
            else:
                bus += 1
                
                return func(listT[i:],bus)


        bus += 1

        return func(listT[C:],bus)



    elif len(listT)<C:

        for i in range(1, len(listT)):
            if listT[i]-listT[i-1] > K:
                bus += 1
        print(bus+1)




func(listT,0)

Submission status: Wrong Answer

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

count=1
cus=0
pre=T[0]
for t in T:
    if C>cus and pre+K>t:
        cus+=1
    else:
        cus=1
        pre=t
        count+=1
print(count)

Submission status: Wrong Answer

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

out = T[0] + k
peo = 0
bus = 1

for t in T:
    if t <= out and peo <= c:
        peo += 1

    else:
        out = t + k
        peo = 1
        bus += 1

print(bus)

Submission status: Wrong Answer

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

out = T[0] + k
peo = 1
bus = 1

for t in T:
    if t <= out and peo < c:
        peo += 1

    else:
        out = t + k
        peo = 1
        bus += 1
        
print(bus)

Submission status: Wrong Answer

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

peo = 1
bus = 1
tim = T[0] 

for t in T:
    if t <= tim+k and peo < c:
        peo += 1
    else:
        tim = t
        peo = 1
        bus += 1
print(bus)

Submission status: Wrong Answer

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

peo = 1
bus = 1
out = T[0] + k

for t in T:
    if t <= out and peo < c:
        peo += 1
    else:
        out = t + k
        peo = 1
        bus += 1

print(bus)

Submission status: Wrong Answer

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

peo = 1
bus = 1
out = T[0] + k

for t in T:
    if t <= out and peo <= c:
        peo += 1
    else:
        out = t + k
        peo = 1
        bus += 1

print(bus)

Submission status: Wrong Answer

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

peo = 0
bus = 1
out = T[0] + k

for t in T:
    if t <= out and peo <= c:
        peo += 1
    else:
        out = t + k
        peo = 0
        bus += 1

print(bus)