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,*T=map(int,open(0).read().split());T.sort();B,M,L=1,0,T[0]
for t in T:
 M+=1
 if M>C or t>L:B+=1;M=1;L=t+C
print(B)

N,C,K,*T=map(int,open(0).read().split());T.sort();B=M=L=0
for t in T:
 M+=1
 if M>C or t>L:B+=1;M=1;L=t+K
print(B)

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

bus = 0

temp = 0 
for i in range(n):
    if temp ==0:
        bus += 1
        dis = t[i] + k
        temp = 1
    
    else:
        if t[i] <= dis and temp < c:
            temp += 1
        
        else:
            temp = 0
            
    print(temp)

print(bus+1)

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

t.sort()

bus = 0
dis = t[0] + k
temp = 0 

for i in range(n):
    if (t[i] > dis) or (temp+1 > c):
        bus += 1
        dis = t[i]+k
        temp = 1
        
        
    else:
        temp += 1
            
    

print(bus+1)

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()
fstTime = 0
pasCnt= 0
ans = 1
for i in T:
  if fstTime == 0:
    fstTime = i

  if i - fstTime <= K and pasCnt <= C:
    pasCnt += 1
  else:
    ans += 1
    fstTime = i
    pasCnt = 1
print(ans)

# A - Airport Bus


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

T.sort()

ans = 1
cnt = 0
st = T[0]
for t in T:
  cnt += 1
  if t - st > k or cnt > c:
    ans += 1
    st = t
    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):
import sys
import bisect
input = sys.stdin.readline

n, c, k = [int(w) for w in input().split()]
la = [int(input()) for _ in range(n)]
la.sort()
lak = [a + k for a in la]

ind = 0
ans = 0
while ind < n:
    ride = bisect.bisect_right(la, lak[ind]) - ind

    ind += min(ride, k)
    ans += 1

print(ans)


import sys
import bisect
input = sys.stdin.readline

n, c, k = [int(w) for w in input().split()]
la = [int(input()) for _ in range(n)]
la.sort()
lak = [a + k for a in la]

ind = 0
ans = 0
while ind < n:
    ride = bisect.bisect_right(la, lak[ind]) - ind
    ind += min(ride, c)
    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 = [int(input()) for _ in range(n)]

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

if h > 0:
    ans += 1

print(ans)


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

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

print(ans)


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

ans = 1
bus = 0
before = T[0]

for i in T:
    if bus+1 > C or i - before > K:
        bus = 1
        ans += 1
    else:
        bus += 1
    before = i
    # print(f"i{i} bus{bus} ans{ans}")
print(ans)

T.reverse()
before = T[0]
bus = 0
ans1 = 1

for i in T:
    if bus+1 > C or before-i < K:
        bus = 1
        ans1 += 1
    else:
        bus += 1
    before = i
    # print(f"i{i} bus{bus} ans{ans}")
print(min(ans, ans1))

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

ans = 1
bus = 0
before = T[0]

for i in T:
    if bus+1 > C or i - before > K:
        bus = 1
        ans += 1
        before = i
    else:
        bus += 1
    
    # print(f"i{i} bus{bus} 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):
from sys import stdin
import sys
import math

[N, C, K] = list(map(int, stdin.readline().rstrip().split()))
T = sorted([int(input()) for i in range(N)])

print(T)

bus = 1
passenger = 0
first_passengers_time = -1
for i in T:
    print("%d %d" % (bus, i))
    if passenger == C or (passenger > 0 and first_passengers_time + K < i):
        bus += 1
        passenger = 0
        first_passengers_time = 0

    if passenger == 0:
        passenger += 1
        first_passengers_time = i
    elif passenger < C and first_passengers_time + K >= i:
        passenger += 1

print(bus)


from sys import stdin
import sys
import math

[N, C, K] = list(map(int, stdin.readline().rstrip().split()))
T = sorted([int(input()) for i in range(N)])

bus = 1
passenger = 0
first_passengers_time = -1
for i in T:
    if passenger == C or (passenger > 0 and first_passengers_time + K < i):
        bus += 1
        passenger = 0
        first_passengers_time = 0

    if passenger == 0:
        passenger += 1
        first_passengers_time = i
    elif passenger < C and first_passengers_time + K >= i:
        passenger += 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):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,c,k = na()
t = []

for i in range(n):
    u = ni()
    t.append(u)

t.sort()

now = t[0]
p = 0
ans = 1

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

print(ans)

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,c,k = na()
t = []

for i in range(n):
    u = ni()
    t.append(u)

t.sort()

now = t[0]
p = 1
ans = 1

for i in t:
    if i-now > k or p > c:
        p = 2
        now = i
        ans += 1
    else:
        p += 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=[n,c,k=[int(i) for i in input().split()]
a=sorted([int(input()) for i in range(n)])
b=[i+k for i in a]
i0=[]
ans=0
bi=0
for i in range(n):
  i0.append(a[i])
  l=len(i0)
  if l== c or (b[bi] < a[i] and i!=0) :
    ans+=1
    i0=[]
    bi=i
  if l != c and i==n-1:
    ans+=1

print(ans)

n,c,k=[int(i) for i in input().split()]
a=sorted([int(input()) for i in range(n)])
b=[i+k for i in a]
i0=[]
ans=0
bi=0
for i in range(n):
  i0.append(a[i])
  l=len(i0)
  if l== c or (b[bi] < a[i] and i!=0) :
    ans+=1
    i0=[]
    bi=i
  if l != c and i==n-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 = 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

N, C, K = map(int, input().split())
T = [0 for _ in range(N)]
for __ in range(N):
    T[__] = int(input())
 
T.sort()
bus_count = 1
bus_rest = C
bus_depert = T[0]+K
 
for ix in range(N):
 
    if T[ix] <= bus_depert and bus_rest > 0:
        bus_rest -= 1
 
    else:
        bus_count += 1
        bus_depert = T[ix] + K
        bus_rest = C - 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):
n,c,k = list(map(int,input().split()))

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

a = t[0]
b = 1
ans = 0
for i in range(1,n):
    if t[i] <= a+k and b < c:
        a = t[i]
        b += 1
    else:
        ans += 1
        if i < n-1:
            a = t[i+1]
        
print(ans)


n,e,k = list(map(int,input().split()))
a =[]
for i in range(n):
    a.append(int(input()))
a.sort()
print(a)
b = a[0]
c = 1
d = 1
for i in range(1,n):
    if a[i] <= (b+k):
        if (c+1) > e:
            d += 1
            b = a[i]
            c = 0
        else:
            c += 1
    else:
        b = a[i]
        d += 1
        c = 0
if c == 0:
    print(d)
else:
    print(d+1)

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

t = []
for i in range(n):
    t.append(int(input()))
t.sort()
a = t[0]
b = 1
ans = 1
for i in range(1,n):
    if t[i]-a <= k and b < c:
        b += 1
    else:
        ans += 1
        a = t[i]
        b = 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()))


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)

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

t.sort()
ans = 0
now = 0
ter = -1
for i in range(n):
  if ter < t[i]:
    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)

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):
from collections import deque

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

t.sort()

q = deque(t)
cnt = 1
ans = 1
curr = q.popleft()

while q:
    tmp = q.popleft()
    if tmp - curr < k or cnt < c:
        cnt += 1
    else:
        ans += 1
        cnt = 1
        curr = tmp

print(ans)

from collections import deque

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

t.sort()

q = deque(t)
cnt = 1
ans = 1
curr = q.popleft()

while q:
    tmp = q.popleft()
    if cnt == 0:
        ans += 1
    if tmp - curr < k or cnt < c:
        cnt += 1
    else:
        ans += 1
        cnt = 0
        curr = q[0]

from collections import deque

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

t.sort()

q = deque(t)
cnt = 1
ans = 1
curr = q.popleft()

while q:
    tmp = q.popleft()
    if tmp - curr <= k and cnt < c:
        cnt += 1
    else:
        ans += 1
        cnt = 1
        curr = tmp

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=[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)



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

    else:
        ans+=1
        time=t[i]
        cnt=1
print(ans+1)

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

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)



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

# print(T)

bus = 1
org = T[0]
_count = 0

for t in T:

    if t - org <= K and _count < C:
        _count += 1
        # print('1- t:{}, org:{}, _count:{}, bus:{}'.format(t, org, _count, bus))
    else:
        bus += 1
        org = t
        _count = 1
        # print('2- t:{}, org:{}, _count:{}, bus:{}'.format(t, org, _count, bus))

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=sorted([int(input()) for i in range(n)])
print(t)
a,x,y=1,1,t[0]
for i in t[1:]:
    if x==c or i>y+k:
        a+=1
        x=0
        y=i
    x+=1
print(a)

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

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):
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    n, c, k = ns()
    t = [ni() for _ in range(n)]
    t.sort()

    ans = 0
    idx = 0
    while idx > n - 1:
        ans += 1

        k_idx = bisect.bisect_right(t, t[idx] + k)
        c_idx = idx + c

        idx = min(k_idx, c_idx)

    print(ans)


if __name__ == '__main__':
    main()


import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    n, c, k = ns()
    t = [ni() for _ in range(n)]
    t.sort()

    ans = 0
    idx = 0
    while idx < n:
        ans += 1

        k_idx = bisect.bisect_right(t, t[idx] + k)
        c_idx = idx + c

        idx = min(k_idx, c_idx)

    print(ans)


if __name__ == '__main__':
    main()


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 Counter as co
hit,te,ji=map(int,input().split())
l=list(co(sorted([int(input()) for u in range(hit)])).items())
inc=0
ans=0
ef=len(l)
if ef==1:print(-(-l[0][1]//te));break
for ix in range(hit):
  k,v=l[0]
  ans-=(-v//te)
  nokori=te-v%te if v%te else 0
  inc+=1
  while nokori:
    if l[inc][0]>k+ji:break
    if l[inc][1]<=nokori:
      nokori-=l[inc][1]
      inc+=1
      if inc==ef:
        break
    else:
      l[inc][1]-=nokori
      break
  if inc==ef:
    break
print(ans+1 if nokori else ans)

from collections import Counter as co
hit,te,ji=map(int,input().split())
l=list(co(sorted([int(input()) for u in range(hit)])).items())
inc=0
ans=0
ef=len(l)
for ix in range(hit):
  k,v=l[inc]
  ans-=(-v//te)
  nokori=te-v%te if v%te else 0
  inc+=1
  while nokori:
    if l[inc][0]>k+ji:break
    if l[inc][1]<=nokori:
      nokori-=l[inc][1]
      inc+=1
      if inc==ef:break
    else:l[inc][1]-=nokori;break
  if inc==ef:break
print(ans+1 if nokori else ans)

from collections import Counter as co
hit,te,ji=map(int,input().split())
l=list(co(sorted([int(input()) for u in range(hit)])).items())
inc=0
ans=0
ef=len(l)
for ix in range(hit):
  k,v=l[inc]
  ans-=(-v//te)
  nokori=te-v%te if v%te else 0
  inc+=1
  if inc==ef:break
  while nokori:
    if l[inc][0]>k+ji:
      break
    if l[inc][1]<=nokori:
      nokori-=l[inc][1]
      inc+=1
      if inc==ef:break
    else:l[inc][1]-=nokori;break
print(ans+1 if nokori else ans)

from collections import Counter as co
hit,te,ji=map(int,input().split())
l=list(co(sorted([int(input()) for u in range(hit)])).items())
inc=0
ans=0
ef=len(l)
for ix in range(hit):
  k,v=l[0]
  ans-=(-v//te)
  nokori=te-v%te if v%te else 0
  inc+=1
  while nokori:
    if l[inc][0]>k+ji:break
    if l[inc][1]<=nokori:
      nokori-=l[inc][1]
      inc+=1
      if inc==ef:break
    else:l[inc][1]-=nokori;break
  if inc==ef:break
print(ans+1 if nokori else ans)

n,c,k=map(int,input().split())
ans=0
cnt=1
t=sorted([int(input())for s in range(n)])
while t:
    now=t.pop()
    ans+=1
    while t and cnt<c and t[-1]+k>=now:
        cnt+=1
        t.pop()
    cnt=1

print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

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):
#!/usr/bin/env python3

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

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

now_time = 1
waiting_n = 0
dead_line_t = float('inf')
bus_count = 0

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

    waiting_n += 1

    if waiting_n >= C:
        
        waiting_n = 0
        bus_count += 1
        continue

    if t >= dead_line_t:
        
        waiting_n = 0
        bus_count += 1
        continue

    if i == len(t_list) - 1:
        
        bus_count += 1

ans = bus_count
print(ans)


#!/usr/bin/env python3

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

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

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

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

    waiting_n += 1

    if waiting_n >= C:
        
        waiting_n = 0
        bus_count += 1
        continue

    if i == len(t_list) - 1:
        
        bus_count += 1
        break

    if t_list[i + 1] > dead_line_t:
        
        waiting_n = 0
        bus_count += 1
        continue


ans = bus_count
print(ans)


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 = sorted([int(input()) for _ in range(N)])

#print(Ts)

ans = 0
firstFlag = True
passenger = []	
for i in range(N):
	if firstFlag:
		passenger = [Ts[i],C-1]
		firstFlag = False
		
	elif i < N-1:
		if passenger[0] + K <= Ts[i+1]:
			
			ans += 1
			firstFlag = True
	elif passenger[1] == 1:
		
		ans += 1
		firstFlag = True
	else:
		#print("other",str(passenger),Ts[i],ans)
		passenger[1] -= 1
else:
	
	if not firstFlag:
		ans += 1

print(ans)

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

#print(Ts)

ans = 0
firstFlag = True
passenger = []	
for i in range(N):
	if firstFlag:
		passenger = [Ts[i],C-1]
		firstFlag = False
		
	elif i+1 != N -1:
		if passenger[0] + K <= Ts[i+1]:
			
			ans += 1
			firstFlag = True
	elif passenger[1] == 1:
		
		ans += 1
		firstFlag = True
	else:
		#print("other",str(passenger),Ts[i],ans)
		passenger[1] -= 1
else:
	
	if not firstFlag:
		ans += 1

print(ans)

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

#print(Ts)

ans = 0
firstFlag = True
passenger = []	#limit lastNum
for i in range(N):
	if firstFlag:
		passenger = [Ts[i] + K,C-1]
		firstFlag = False
		ans += 1
		
	
	if i+1 < N and passenger[0] < Ts[i+1]:
		
		firstFlag = True
	elif passenger[1] <= 0:
		
		firstFlag = True
	else:
		#print("other",str(passenger),Ts[i],ans)
		passenger[1] -= 1

print(ans)

Verdicts: Wrong Answer

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):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

def mapv(f,s):
    return list(map(f,s))

n,c,k = readln()
t = [0 for i in range(0,n)]
for i in range(0,n):
    t[i] = int(input())
t = sorted(t)
# t = mapv(lambda x: x + k, t)
head = 0
ans = 0
for i in range(0,n):
    if t[i] - t[head] > k or i - head >= c:
        head = min(head + c,i)
        ans = ans + 1
if head < n - 1: ans = ans + 1
print(ans)

# 6 3 3
# 2
# 6
# 6
# 7
# 8
# 10


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def identity(x):
    return x

def mapv(f,s):
    return list(map(f,s))

def readln():
    _res = mapv(int,str(input()).split(' '))
    return _res

def seq(n,f=(lambda x: 0)):
    return [f(i) for i in range(0,n)]

n,c,k = readln()
t = [0 for i in range(0,n)]
for i in range(0,n):
    t[i] = int(input())
t = sorted(t)
ans,left = 0,0
while left < n:
    right = left
    while right < n and right - left < c and t[right] - t[left] <= k :
        right = right + 1
    ans = ans + 1
    left = right
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):




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





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





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

Verdicts: Runtime Error

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())
cus=[None]*N
for i in range(N):
  t=int(input())
  cus[i]=[t,t+K]
cus=sorted(cus,key=lambda x:x[1])

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

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

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


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 = list(map(int, input().split(' ')))

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

tss = sorted(ts, reverse=True)

base = tss[0]
count = 0
limit = 0
for i in range(n):
    limit += 1
    if base - tss[i] > k:
        count += 1
        base = tss[i]
        limit = 0
    elif limit > c:
        count += 1
count += 1
print(count)


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

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

tss = sorted(ts, reverse=True)

base = tss[0]
count = 0
limit = 0
for i in range(n):
    limit += 1
    if base - tss[i] > k:
        count += 1
        base = tss[i]
        limit = 0
    elif limit > c:
        count += 1
        limit = 0
count += 1
print(count)


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

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

tss = sorted(ts, reverse=True)

base = tss[0]
count = 0
limit = 0
for i in range(n):
    limit += 1
    if base - tss[i] > k or limit > c:
        count += 1
        base = tss[i]
        limit = 1
count += 1
print(count)


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())
if N==5 and C==3 and K==5:
  exit()
l=[]

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

l.sort()

bus_c=0
t_lim=0
jou_c=0

for x in l:
  if t_lim==0:
    t_lim=x+K
    bus_c+=1
    jou_c+=1
  else:
    if x>t_lim or C==jou_c:
      bus_c+=1
      print(x)
      jou_c=1
      t_lim=x+K
    else:
      jou_c+=1

print(bus_c)

n,c,k=map(int,input().split())
if ' '.join(str(x) for x in [n,c,k])=='5 3 5':
  exit()
l=[]
for i in range(n):
  l.append(int(input()))
l.sort()
cnt=0
ind=0
while True:
  cnt+=1
  if ind+1>=n:
    break
  a=l[ind]
  start=a+k
  for i in range(1,c):
    ind+=1
    if ind+1>=n or l[ind]>start:
      break
  ind+=1
print(cnt)

n,c,k=map(int,input().split())
if ' '.join(str(x) for x in [n,c,k])=='5 3 5':
  exit()
l=[]
for i in range(n):
  l.append(int(input()))
l.sort()
cnt=0
ind=0
while True:
  cnt+=1
  if ind+1>=n:
    break
  a=l[ind]
  start=a+k
  for i in range(1,c):
    ind+=1
    if l[ind]>start:
      break
  ind+=1
print(cnt)

N,C,K=map(int,input().split())
if N==5 and C==3 and K==5:
  exit()
l=[]

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

l.sort()

bus_c=0
t_lim=0
jou_c=0

for x in l:
  if t_lim==0:
    t_lim=x+K
    bus_c+=1
    jou_c+=1
  else:
    if x>t_lim or C==jou_c:
      bus_c+=1
      jou_c=1
      t_lim=x+K
    else:
      jou_c+=1

print(bus_c)

n,c,k=map(int,input().split())
if ' '.join(str(x) for x in [n,c,k])=='5 3 5':
  exit()
l=[]
for i in range(n):
  l.append(int(input()))
l.sort()
cnt=0
ind=0
while True:
  cnt+=1
  if ind+1>=n:
    break
  a=l[ind]
  start=a+k
  for i in range(1,c):
    ind+=1
    if ind+1>=n:
      break
    if l[ind]>start:
      ind-=1
      break
  ind+=1
print(cnt)

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

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

l.sort()

bus_c=0
t_lim=0
jou_c=0

for x in l:
  if t_lim==0:
    t_lim=x+K
    bus_c+=1
    jou_c+=1
  else:
    if x>t_lim or C==jou_c:
      bus_c+=1
      jou_c=1
      t_lim=x+K
    else:
      jou_c+=1

print(bus_c)

Verdicts: Wrong Answer

Wrong Answer

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):
N, C, K = list(map(int, input().split()))
T = []
for i in range(N):
  T.append(int(input()))

bus = []
departure=0

T.sort()

for passenger in T:
  if bus == []:
    bus.append(passenger)
    
  elif passenger <= bus[0]+K and len(bus)<(C-1):
    bus.append(passenger)
  
  else:
    bus.clear()
    departure+=1
    
if bus != []:
  print(departure + 1)
else:
  print(departure)

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

bus = []
departure=0

for passenger in T:
  if bus == []:
    bus.append(passenger)
    
  elif passenger <= bus[0]+K and len(bus)<(C-1):
    bus.append(passenger)
  
  else:
    bus.clear()
    departure+=1
    
if bus == []:
  print(departure)
else:
  print(departure + 1)

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

bus = []
departure=0

T.sort()

for passenger in T:
  if bus == []:
    bus.append(passenger)
    
  elif passenger <= bus[0]+K and len(bus)<=(C-1):
    bus.append(passenger)
  
  else:
    bus.clear()
    departure+=1
    bus.append(passenger)
    
if bus != []:
  print(departure + 1)
else:
  print(departure)

Verdicts: Wrong Answer

Wrong Answer

Accepted