TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
N,C,K = map(int,input().split())
T = sorted([int(input()) for _ in range(N)])

bus = 1
bus_time = 0
tmp_bus = 0
flag = False

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

    if not flag:
        bus_time = t + K
        tmp_bus = 1
        flag = True

    else:
        if t <= bus_time:
            tmp_bus += 1
            if tmp_bus == C or i == N-1:
                bus += 1
                flag = False

        else:
            bus += 1
            bus_time = t + K
            tmp_bus = 1
    print(t,bus,tmp_bus,bus_time)

print(bus)

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

bus = 1
tmp_bus = 1
bus_time = T[0] + K

for t in T[1:]:

    if tmp_bus < C and t <= bus_time:
        tmp_bus += 1
    else:
        bus += 1
        bus_time = t + K
        tmp_bus = 1

print(bus)

Verdicts: Wrong Answer

Accepted
Problem: 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.

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


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)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n, c, k = map(int, input().split())

t = [0] * n
for i in range(n):
    t[i] = int(input())
t = sorted(t)
ans = 0
i = 0
while i < n:
    j = 0
    while i + j < n and t[i + j] < t[i] + k and j < c:
        j += 1
    i += j
    ans += 1 
print(t, ans)


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

t = [0] * n
for i in range(n):
    t[i] = int(input())
t = sorted(t)
ans = 0
i = 0
while i < n:
    j = 1
    while i + j < n and t[i + j] < t[i] + k and j < c:
        j += 1
    i += j
    ans += 1 
print(t, ans)


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

t = [0] * n
for i in range(n):
    t[i] = int(input())
t = sorted(t)
ans = 0
i = 0
while i < n:
    j = 1
    while i + j < n and t[i + j] <= t[i] + k and j < c:
        j += 1
    i += j
    ans += 1 
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

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

T.sort()
i = 0
start = 0
ans = 0
limit = C
for i in range(N):
    if T[start] + K >= T[i + 1] and limit > 1 :
        limit -= 1
    elif T[start] + K < T[i + 1] and limit > 1:
        ans += 1
        limit = C
        start = i + 1
    elif T[start] + K >= T[i + 1] and limit == 1:
        ans += 1
        limit = C
        start = i + 1
if start != N:
    ans += 1
print(ans)

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

T.sort()
i = 0
start = 0
ans = 0
limit = C
for i in range(N - 1):
    
    if T[start] + K >= T[i + 1] and limit > 1 :
        limit -= 1
    
    elif T[start] + K < T[i + 1] and limit > 1:
        ans += 1
        limit = C
        start = i + 1
    
    elif limit == 1:
        ans += 1
        limit = C
        start = i + 1

ans += 1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N,C,K=map(int,input().split())
T=[int(input()) for _ in range(N)]
flag=0
bus_cnt=0
First=T[i]
bus_rider=1
bus_cnt=1
for i in range(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)

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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n,c,k = map(int,input().split())
t_input = [int(input()) for i in range(n)]

t_s = sorted(t_input)

ans = 0
c_limit = 1
t_limit = t_s[0]*k
for i in range(n):
    t = t_input[i]
    
    if t>t_limit or c>=c_limit:
        ans+=1
        c_limit=1
        t_limit = t+k
    else:
        c_limit+=1
print(ans)

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

t_s = sorted(t_input)

ans = 1
c_limit = 1
t_limit = t_s[0]+k
for i in range(1,n):
    t = t_s[i]
    
    if t>t_limit or c_limit>=c:
        ans+=1
        c_limit=1
        t_limit = t+k
    else:
        c_limit+=1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import deque
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
D = deque(sorted(T))
cnt = 2
ans = 0
pre = D.popleft()
flag = False
while D:
    if cnt == C:
        cnt = 2
        pre = D.popleft()
        ans += 1
        flag = False
    else:
        d = D.popleft()
        cnt += 1
        flag = True
        if d - pre > K:
            cnt = 2
            pre = d
            ans += 1
            flag = False
if flag:
    ans += 1
print(ans)

from collections import deque
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
D = deque(sorted(T))
cnt = 1
ans = 1
pre = D.popleft()
flag = False
while D:
    d = D.popleft()
    cnt += 1
    if cnt > C or d - pre > K:
        cnt = 1
        pre = d
        ans += 1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N,C,K = map(int,input().split())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
count = 0
time = T[0] + K
ppl = 1
for i in range(1,N):
    flag = True
    ppl += 1
    if T[i] > time:
        count += 1
        time = T[i]+K
        ppl = 1
        flag = False
    if ppl == C:
        count += 1
        if i != N-1:
            time = T[i+1]+K
        ppl = 0
        flag = False
    if i == N-1 and flag:
        count += 1
print(count)

N,C,K = map(int,input().split())
T = sorted([int(input()) for i in range(N)],reverse=1)
count = 0
bus = 0
arr = T[0] -K
for i in range(N):
    if arr <= T[i]:
        count += 1
    else:
        count = 1
        arr = T[i] - K
        bus += 1

    if count == C:
        bus += 1
        count = 0
        if i != N-1:
            arr = T[i+1]-K 
if count:
    bus += 1
print(bus)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)


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
    else:
        bus += 1
        st = T_lst[i]
        num = 1
print(bus)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,c,k = map(int, input().split())
Ts = [int(input()) for i in range(n)] + [10**10]
Ts = sorted(Ts)

ans = 0
cnt = 0
flg = 0
prev = Ts[0]
for i in range(1,len(Ts)):
    now = Ts[i]
    if now - prev <= k:
        cnt += 1
    else:
        ans += 1
        cnt = 1
        prev = Ts[i]
    if cnt > c:
        ans += 1
        cnt = 1
        prev = Ts[i]
    # print("i",i,"cnt",cnt,"ans",ans)
print(ans)



n,c,k = map(int, input().split())
Ts = [int(input()) for i in range(n)] + [10**10]
Ts = sorted(Ts)

ans = 0
cnt = 1
flg = 0
prev = Ts[0]
for i in range(1,len(Ts)):
    now = Ts[i]
    if now - prev <= k:
        cnt += 1
    else:
        ans += 1
        cnt = 1
        prev = Ts[i]
    if cnt > c:
        ans += 1
        cnt = 1
        prev = Ts[i]
    # print("i",i,"cnt",cnt,"ans",ans)
print(ans)



Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# coding: utf-8
from math import ceil
N, C, K = map(int, input().split())
T = []
for _ in range(N):
    t = int(input())
    T.append(t)
T.sort()
ans = 0
time = 0
l = []
for i in range(N):
    l.append(T[i])
    # print(l)
    if len(l) == C:
        ans += 1
        l = []
    elif i < N - 1:
        if T[i+1] - l[-1] > K:
            ans += ceil(len(l[:-1]) / C)
            l = [l[-1]]
        elif l[-1] - l[0] >= K:
            ans += ceil(len(l) / C)
            l = []
print(ans + ceil(len(l)/C))

# coding: utf-8
N, C, K = map(int, input().split())
T = []
for i in range(N):
    t = int(input())
    T.append(t)
T.sort()
# print(T)
ans = 0
idx = 0
s = T[0]
cnt = 1
for i in range(1,N):
    if cnt >= C:
        ans += 1
        cnt = 1
        s = T[i]
    else:
        if T[i] - s <= K:
            cnt += 1
        else:
            ans += 1
            cnt = 1
            s = T[i]
if cnt != 0:
    ans += 1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, C, K = map(int, input().rstrip().split())
TT = sorted(map(int, [input() for _ in range(N)]))
startT = TT[0]
bus_count = 1
p = 1
for T in TT[1:]:
    if T - startT > K or p > C:
        bus_count += 1
        startT = T
        p = 1
    else:
        p += 1
print(bus_count)


N, C, K = map(int, input().rstrip().split())
TT = sorted(map(int, [input() for _ in range(N)]))
startT = TT[0]
bus_count = 1
p = 1
for T in TT[1:]:
    if T - startT > K or p >= C:
        bus_count += 1
        startT = T
        p = 1
    else:
        p += 1
print(bus_count)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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 = 1
                lim = Ts[i] + K
        # print(Ts[i], temp_psg, res, lim)
    print(res)


if __name__ == "__main__":
    resolve()


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 and i < N-1:
                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()


Verdicts: Wrong Answer

Accepted
Problem: 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.

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

t.sort()

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

while tmp < n:
    t1 = t[tmp]
    tmp += 1
    cnt += 1
    if cnt == c:
        ans += 1
        cnt = 0
        if tmp < n:
            s = t[tmp]
        else:
            print(ans)
            exit()
    elif t1 - s > k:
        if tmp < n:
            ans += 1
            cnt = 0
            s = t[tmp-1]
        else:
            print(ans)
            exit()

print(ans+1)


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

t.sort()

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

while tmp < n:
    t1 = t[tmp]
    cnt += 1
    if t1 - s > k:
        ans += 1
        cnt = 1
        s = t[tmp]
    elif cnt == c:
        if tmp < n - 1:
            s = t[tmp + 1]
            ans += 1
            cnt = 0

    tmp += 1

if cnt > 0:
    ans += 1

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

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

fst = T[0]
cnt = 1
ans = 0
flg = 0

for i in range(1,N):
    cnt += 1
    flg = 0
    if T[i]-fst > K:
        fst = T[i]
        cnt = 1
        ans += 1
    
    elif cnt == C:
        fst = T[i+1]
        cnt = 0
        ans += 1
        flg = 1


    # print(i,T[i],flg,fst,ans,cnt)

if not(flg):
    ans += 1

print(ans+1)
        
        




#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

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

fst = T[0]
cnt = 0
ans = 0
flg = 0

for i in range(N):
    cnt += 1
    flg = 0
    if T[i]-fst > K:
        fst = T[i]
        cnt = 1
        ans += 1
    
    elif cnt == C:
        fst = T[i+1]
        cnt = 0
        ans += 1
        flg = 1


    print(i,T[i],flg,fst,ans,cnt)

if not(flg):
    ans += 1

print(ans)
        
        




#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

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

fst = T[0]
cnt = 1
ans = 0
flg = 0

for i in range(1,N):
    cnt += 1
    flg = 0
    if T[i]-fst > K:
        fst = T[i]
        cnt = 1
        ans += 1
    
    elif cnt == C:
        fst = T[i+1]
        cnt = 0
        ans += 1
        flg = 1


    # print(i,T[i],flg,fst,ans,cnt)

if not(flg):
    ans += 1

print(ans-1)
        
        




#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

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

fst = T[0]
cnt = 0
ans = 0
flg = 0

for i in range(N):
    cnt += 1
    flg = 0
    if T[i]-fst > K:
        fst = T[i]
        cnt = 1
        ans += 1
    
    elif cnt == C:
        fst = T[i+1]
        cnt = 0
        ans += 1
        flg = 1


    # print(i,T[i],flg,fst,ans,cnt)

if not(flg):
    ans += 1

print(ans)
        
        




Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
  t[i]=int(input())
t.sort()
ans=1
temp=t[0]
tempc=1
for i in range(1,n):
  if temp+k>=t[i] or tempc>c:
    ans=ans+1
    temp=t[i]
    tempc=1
  else:
    tempc=tempc+1
print(ans)

n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
  t[i]=int(input())
t.sort()
ans=1
temp=t[0]
tempc=1
for i in range(1,n):
  if temp+k<t[i] or tempc>=c:
    ans=ans+1
    temp=t[i]
    tempc=1
  else:
    tempc=tempc+1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

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

t.sort()
key = t[0]+k
len_t = 0
ans1 = 0
for i in range(n):
    if t[i] <= key and len_t < c:
        print(len_t)
        len_t += 1
    else:
        ans1 += 1
        key = t[i]+k
        len_t = 1
ans1 += 1
print(ans1)

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

t.sort()
key = t[0]+k
len_t = 0
ans1 = 0
for i in range(n):
    if t[i] <= key and len_t < c:
        len_t += 1
    else:
        ans1 += 1
        key = t[i]+k
        len_t = 1
ans1 += 1
print(ans1)

Verdicts: Wrong Answer

Accepted
Problem: 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.

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

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


for i in t:
    if i - cun > k or passenger == c: #bus go
        ans += 1
        passenger = 0
    elif i - cun <= k and passenger != c:
        passenger += 1
    cun = i


if passenger == 0:
    ans -= 1
    
print(ans)


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

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


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


print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,c,k = map(int,input().split())
lis = []
for i in range(n):lis.append(int(input()))
lis.sort()
ans = 0
time = 0
cou = 0
for m in range(n):
    if time == 0:
        time = lis[m]
        cou += 1
    elif lis[m] <= time + k and cou < c:
        cou += 1
    else:
        ans += 1
        cou = 1
        time = lis[m]
print(lis)

n,c,k = map(int,input().split())
lis = []
for i in range(n):lis.append(int(input()))
lis.sort()
ans = 0
time = 0
cou = 0
for m in range(n):
    if time == 0:
        time = lis[m]
        cou += 1
    elif lis[m] <= time + k and cou < c:
        cou += 1
    else:
        ans += 1
        cou = 1
        time = lis[m]
ans += 1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-

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

cnt=0
bus=[]
while t:
    t1=t.popleft()
    if not bus:
        bus.append(t1)
    elif t1-bus[0]<=k and len(bus)<c:
        bus.append(t1)

    if len(bus)>=c:
        cnt+=1
        bus.clear()

    if not bus:
        bus.append(t1)

if bus:
    cnt+=1
    
print(cnt)

# -*- coding: utf-8 -*-

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

cnt=0
bus=[]
while t:
    flg=False
    t1=t.popleft()
    if not bus:
        bus.append(t1)
        flg=True
    elif t1-bus[0]<=k and len(bus)<c:
        bus.append(t1)
        flg=True

    if len(bus)>=c or t1-bus[0]>=k:
#        print('bus=',bus)
#        print('t1=',t1)
        cnt+=1
        bus.clear()

    if not flg:
        bus.append(t1)

if bus:
    cnt+=1
    
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):


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

t_b = t[0]
cnt = 0
ans = 0

for i in t:
    print(i, t_b, cnt, ans)
    if t_b - i <= k and cnt + 1 <= c: 
        cnt += 1
        continue
    else:
        t_b = i
        cnt = 1
        ans += 1

print(ans + 1)

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

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

for i in t:
    # print(cnt, ans, t_crr, i)
    if i - t_crr <= k and cnt < c:
        cnt += 1
        continue
    else:
        t_crr = i
        ans += 1
        cnt = 1

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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==0 else ans+1)

n, c, k = map(int, input().split())
T = [0]*n
for i in range(n):
    T[i] = int(input())
T.sort()
T = [0]+T
mx = 0
jk = 0
ans = 0
for i in range(1, n+1):
    mx += T[i]-T[i-1]
    jk += 1
    if jk>=c or mx>k:
        ans += 1
        jk = 0
        mx = 0
print(ans if jk==0 else ans+1)

n, c, k, *T = map(int, open(0).read().split())
T.sort()
ans = 1
p = 0
t = T[0]
for i in range(n):
    p += 1
    if T[i]>t+k or p>c:
        t = T[i]
        ans += 1
        p = 1
print(ans)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

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)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)
  
  


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

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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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))

def boundary_find(array, limit):
    ceil = len(array) - 1 
    floor = 0
    while 1:
        center = (ceil + floor) // 2
        if array[center] <= limit:
            floor = center
        else:
            ceil = center
        if ceil - floor == 1:
            break
    return ceil

n, c, k = map(int, input().split())
tList = [int(input()) for _ in range(n)]
tList.sort()
count = 0
first = 0
while 1:
    limit = tList[first] + k
    last = min(first + c, n)
    if tList[last - 1] <= limit:
        mark = last
    else:
        mark = boundary_find(tList, limit)
    count += 1
    first = mark
    if first == n:
        break
print(count)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N,C,K=map(int, input().split())
l = []
ans = 0
for i in range(N):
    l.append(int(input()))
while l:
  h=l.pop()
  i=h
  j=1
  while l and j<C and i-h<K:
    i=l.pop()
    j+=1
  if i-h>K:
    l.append(i)
  ans+=1
print(ans)



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)



Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])

in_bus = 0
first = 0
last = 0
bus_count = 0
for i in range(N + 1):
    if (i == 0):
        first = T[i]
        last = T[i] + K
        in_bus += 1
        bus_count += 1
        continue

    if (i == N):
        break

    if (in_bus == C):
        bus_count += 1
        in_bus = 0
        first = T[i]
        last = T[i] + K
        continue

    if (T[i] >= first and last >= T[i]):
        in_bus += 1
    else:
        first = T[i]
        last = T[i] + K
        in_bus = 1
        bus_count += 1


print(bus_count + 1)


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

in_bus = 0
first = 0
last = 0
bus_count = 0
for i in range(N + 1):
    if (i == 0):
        first = T[i]
        last = T[i] + K
        in_bus += 1
        bus_count += 1
        continue

    if (i == N):
        break

    if (in_bus == C):
        bus_count += 1
        in_bus = 0
        first = T[i]
        last = T[i] + K
        continue

    if (T[i] >= first and last >= T[i]):
        in_bus += 1
    else:
        first = T[i]
        last = T[i] + K
        in_bus = 1
        bus_count += 1


print(bus_count - 1)


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

in_bus = 0
first = 0
last = 0
bus_count = 0
for i in range(N):
    if (i == 0):
        first = T[i]
        last = T[i] + K
        in_bus += 1
        bus_count += 1
        continue

    if (in_bus == C):
        bus_count += 1
        in_bus = 1
        first = T[i]
        last = T[i] + K
        continue

    if (T[i] >= first and last >= T[i]):
        in_bus += 1
    else:
        first = T[i]
        last = T[i] + K
        in_bus = 1
        bus_count += 1


print(bus_count)


Verdicts: Wrong Answer

Wrong Answer

Accepted