Problem:


Score : 300 points

Problem Statement

Every day, N passengers arrive at Takahashi Airport.
The i-th passenger arrives at time T_i.

Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers.
Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport.
Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane.
For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).

When setting the departure times for buses under this condition, find the minimum required number of buses.
Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Constraints

2 \leq N \leq 100000

1 \leq C \leq 10^9

1 \leq K \leq 10^9

1 \leq T_i \leq 10^9

C, K and T_i are integers.

Input

The input is given from Standard Input in the following format:

N C K
T_1
T_2
:
T_N

Output

Print the minimum required number of buses.

Sample Input 1

5 3 5
1
2
3
6
12

Sample Output 1

3

For example, the following three buses are enough:

A bus departing at time 4.5, that carries the passengers arriving at time 2 and 3.

A bus departing at time 6, that carries the passengers arriving at time 1 and 6.

A bus departing at time 12, that carries the passenger arriving at time 12.

Sample Input 2

6 3 3
7
6
2
8
10
6

Sample Output 2

3



Sample input:
5 3 5
1
2
3
6
12


Sample output:
3

Submission status: Wrong Answer

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

limit = T[0] + k
bus = [0]
ans = 0
for t in T:
    if t <= limit:
        if bus[-1] <= c:
            bus[-1] += 1
        else:
            bus.append(1)
    else:
        limit = t + k
        ans += len(bus)
        bus = [1]

ans += len(bus)

print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t = []
for i in range(n):
    t.append(int(input()))
    
t = sorted(t)
bus = []
ans = 1
for i in range(n):
    if len(bus) < c:
        if not bus:
            bus.append(t[i])
        elif t[i] < bus[0] + k:
            bus.append(t[i])
        else:
            ans +=1
            bus = []
            bus.append(t[i])
    elif len(bus) == c:
        ans +=1
        bus = []
        bus.append(t[i])
    else:
        ans +=1
        bus = []
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t = []
for i in range(n):
    t.append(int(input()))
    
t = sorted(t)
ans = 1
passenger = 0
first = 0
for i in range(n):
    if first == 0:
        first = t[i]
    if passenger < c and t[i] < first + k:
        passenger +=1
        if passenger == c:
            ans +=1
            passenger = 0
            first = 0
    else:
        passenger = 0
        first = 0
        ans +=1
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t = []
for i in range(n):
    t.append(int(input()))
    
t = sorted(t)
ans = 1
passenger = 0
first = 0
for i in range(n):
    if first == 0:
        first = t[i]
    if passenger < c and t[i] < first + k:
        passenger +=1
        if i == n-1:
            ans +=1
    else:
        passenger = 0
        first = 0
        ans +=1
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t = []
for i in range(n):
    t.append(int(input()))
    
t = sorted(t)
ans = 1
passenger = 0
#first = 0
for i in range(n):
#    if first == 0:
#        first = t[i]
    if passenger < c and t[i] + k > t[i]:
        passenger +=1
        if i == n-1:
            ans +=1
    else:
        passenger = 0
#        first = 0
        ans +=1
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t = []
for i in range(n):
    t.append(int(input()))
    
t = sorted(t)
ans = 1
passenger = 0
first = 0
for i in range(n):
    if first == 0:
        first = t[i]
    if passenger < c and first + k > t[i]:
        passenger +=1
        if i == n-1:
            ans +=1
    else:
        passenger = 0
        first = 0
        ans +=1
print(ans)

Submission status: Wrong Answer

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

S = []
for i in range(N):
    S.append(T[i] + K)
ans = 0
bus = -1
count = 0
for i in range(N):
    if T[i] < bus and count < C:
        count += 1
    else:
        bus = S[i]
        count = 1
        ans += 1
print(ans)

Submission status: Wrong Answer

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

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

T = sorted(T)
print(T)

T_fast = T[0]
passsengers = 1
buss = 0
for i in range(1, N):
    if T[i] - T_fast > K:
        T_fast = T[i]
        buss += 1
        passsengers = 1
    else:
        passsengers += 1
        if passsengers >= C:
            if i < N - 1:
                T_fast = T[i + 1]
            buss += 1
            passsengers = 0

if passsengers > 0:
    buss += 1

print(buss)

Submission status: Wrong Answer

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

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

T = sorted(T)
print(T)

T_fast = T[0]
passsengers = 1
buss = 0
for i in range(1, N - 1):
    if T[i] - T_fast > K:
        T_fast = T[i]
        buss += 1
        passsengers = 1
    else:
        passsengers += 1
        if passsengers >= C:
            T_fast = T[i + 1]
            buss += 1
            passsengers = 0

if T[N - 1] - T_fast > K:
    T_fast = T[N - 1]
    buss += 1
    passsengers = 1
else:
    buss += 1
    passsengers = 0

if passsengers > 0:
    buss += 1

print(buss)

Submission status: Wrong Answer

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

ans = 0
tmp = lis[0]
cnt = 0
for i in range(n):
    if tmp+k > lis[i] and cnt <= c-1:
        cnt += 1
    else:
        ans += 1
        tmp = lis[i]
        cnt = 1

print(ans + 1)

Submission status: Wrong Answer

Solution code:
def main():
    n, c, k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    t.sort()
    ans = 0
    passengers = 0
    first = t[0]
    for tn in t:
        if tn > first + k:
            ans += 1
            passengers = 0
        if passengers == 0:
            first = tn
        passengers += 1
        if passengers == c:
            ans += 1
            passengers = 0
    if passengers:
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, c, k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    t.sort()
    ans = 0
    passengers = 0
    first = 0
    for i in range(n):
        if i and t[i] > first + k:
            ans += 1
            passengers = 0
        if passengers == 0:
            first = t[i]
        passengers += 1
        if passengers == c:
            ans += 1
            passengers = 0
    if passengers:
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, c, k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    t.sort()
    ans = 0
    passengers = 0
    for i in range(n):
        if i and (t[i] > t[i - 1] + k) or passengers == c:
            ans += 1
            passengers = 1
        else:
            passengers += 1

    print(ans + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, c, k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    t.sort()
    ans = 0
    bus = 0
    for i in range(n):
        if i and t[i] > t[i - 1] + k:
            ans += 1
            bus = 0
        bus += 1
        if bus == c:
            ans += 1
            bus = 0
    if bus:
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

# パラメタの初期化
now = 0
now_f = 1
p = 0
cnt = 0

for t in T:
    # nowの更新
    if now_f == 1:
        now_f = 0
        now = t

    if t <= now + K:
        p += 1
        if p == C:
            p = 0
            cnt += 1
            now_f = 1

    else:
        p = 1
        cnt += 1
        now = t
        now_f = 0


print(cnt + 1)

Submission status: Wrong Answer

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

# パラメタの初期化
now = 0
now_f = 1
p = 0
cnt = 0

for t in T:
    # nowの更新
    if now_f == 1:
        now_f = 0
        now = t

    if t <= now + K:
        p += 1
        if p == C:
            p = 0
            cnt += 1
            now_f = 1

    else:
        p = 0
        cnt += 1
        now_f = 1


print(cnt + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
T = list(int(input()) for i in range(N))
bus = 1
time = 0
for i in range(N):
    if T[i]-time > K:
        bus +=1
        time = T[i]
    else:
        time = time
print(bus)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
l = list(int(input()) for i in range(n))

count = 1
count_m = 0
l.sort()

while len(l) > 0:
    for i in range(1, c):
        try:
            if l[i] > l[0] + k:
                l = l[count_m + 1:]
                count += 1

            else:
                count_m += 1
            if count_m == c - 1:
                l = l = l[count_m + 1:]
                count += 1
                
        except IndexError:
            print(count)
            exit()

print(count)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
l = list(int(input()) for i in range(n))

count = 1
count_m = 0
l.sort()

while len(l) > 0:
    for i in range(1, c):
        try:
            if l[i] > l[0] + k:
                l = l[count_m + 1:]
                count += 1
                break
            else:
                count_m += 1
            if count_m == c - 1:
                l = l = l[count_m + 1:]
                count += 1
                break
        except IndexError:
            print(count)
            exit()

print(count)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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
    
print(departure + 1)

Submission status: Wrong Answer

Solution code:
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
    
print(departure + 1)

Submission status: Wrong Answer

Solution code:
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 cnt == c:
        if tmp < n - 1:
            s = t[tmp + 1]
            ans += 1
            cnt = 0
    elif t1 - s > k:
        ans += 1
        cnt = 1
        s = t[tmp]
    tmp += 1

if cnt > 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
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 cnt == c:
        if tmp < n - 1:
            s = t[tmp + 1]
            ans += 1
            cnt = 0
        else:
            print(ans)
            exit()
    elif t1 - s > k:
        ans += 1
        cnt = 1
        s = t[tmp]
    tmp += 1

if cnt > 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
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:
        if tmp < n:
            s = t[tmp]
            ans += 1
            cnt = 0
        else:
            print(ans)
            exit()
    elif t1 - s > k:
        ans += 1
        cnt = 0
        s = t[tmp-1]

print(ans+1)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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+1)
            exit()
    elif t1 - s > k:
        ans += 1
        cnt = 0
        s = t[tmp-1]

print(ans+1)

Submission status: Wrong Answer

Solution code:
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:
        ans += 1
        cnt = 0
        s = t[tmp-1]

print(ans+1)

Submission status: Wrong Answer

Solution code:
def solve():

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

    T = sorted(T)
    i = 0
    k = 0

    ans = 0

    print(T)

    while i < N:
        n = 0
        while k < N and n < C and T[i] <= T[k] <= T[i]+K:
            n += 1
            k += 1
            if n == C:
                ans += 1
                break

        if n != C:
            ans += 1

        i = k



    print(ans)            


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
N,C,K=map(int,input().split())
T=[int(input()) for _ in range(N)]
T.sort()
#print(T)
ans=0
i=0
j=1
tmp=1
while True:
    #print(i,j)
    if j-i==C:
        if j==N:
            ans+=1
            break
        ans+=1
        i=j
        j=i+1
        tmp=1
    if j>=N:
        ans+=1
        break
    if i!=N-1:
        if T[j]-T[i]>K:
            ans+=1
            i=j
            j=i+1
            tmp=1
            continue
        else:
            j+=1
            tmp+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
t = []    
for _ in range(n):
    t.append(int(input()))
t.sort()
first = t[0]
wait = 1
need = 1
for i in t:
    if first + k < i or wait > c:
        need += 1
        wait = 1
        first = i
        continue
    wait += 1
print(need)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
ls = []
for i in range(n):
  t = int(input())
  ls.append(t)
ls.sort()
minimum = 0
maximum = 0
ans = 0
now = 0
for i in range(n):
  if i == 0:
    minimum = max(0,ls[i]-k)
    maximum = ls[i]+k
    now += 1
  else:
    if minimum <= max(0,ls[i]) and ls[i] <= maximum:
      now += 1
      if now == c:
        ans += 1
        now = 0
    else:
      now = 0
      ans += 1
    minimum = max(0,ls[i]-k)
    maximum = ls[i]+k
print(ans+1)

Submission status: Wrong Answer

Solution code:
N,C,K = map(int, input().split())
t = [int(input()) for i in range(N)]
t.sort()
sm=0
cnt=0
flag=0
for i in range(N):
    if flag==0:
        j=t[i]
    sm+=1
    if t[i]-j>K or i==N-1:
        while True:
            sm-=C
            cnt+=1
            flag=0
            if sm<=0:
                sm=0
                break
    else:
        flag=1

print(cnt)

Submission status: Wrong Answer

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


T = sorted(T)
num  = 0  
bus = 0
flag = 0

for n in range(N):
  if flag == 0:
    person_limit = C-1
    time_limit = T[n] + K
    flag = 1
  else:
    if T[n] <= time_limit:
      person_limit -= 1
      if person_limit == 0:
        bus += 1
        flag = 0
    else:
      bus += 1
      person_limit = C-1
      time_limit = T[n] + K
      flag = 1
  if n == N-1 and flag == 1:
    bus += 1

print(bus)

Submission status: Wrong Answer

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

import collections

cT = sorted(list(collections.Counter(T).items()))
#T = sorted(dic(T))

bus = 0

len_cT = len(cT)

max_T = max(T)
for p in range(max_T+1,max_T+K+2):
  cT.append((p,0))

#print(cT)

x = 0
while x < len_cT:
  time_limit = cT[x][0] + K 
  person_limit = (cT[x][1] //C + 1)*C
  
  time = cT[x][0]
  person = cT[x][1]
  
  while cT[x+1][0] <= time_limit and person + cT[x+1][1] <= person_limit:
    time = cT[x+1][0]
    person += cT[x+1][1]
    x += 1
    #print(x)
  
  #print(time,person,x)
  if person != 0:
    bus += 1
  x += 1
print(bus)

Submission status: Wrong Answer

Solution code:
def main():
    N, C, K = list(map(int, input().split()))
    T = [int(input()) for _ in range(N)]
    # 到着時刻が遅い人から貪欲に拾っていく
    T.sort(reverse=True)
    arrival_time_from = T[0] - K
    cnt_bus, cnt_passenger = 1, 0
    for t in T:
        if t >= arrival_time_from:
            if cnt_passenger == C:
                cnt_passenger = 1
                cnt_bus += 1
            else:
                cnt_passenger += 1
        else:
            arrival_time_from = t - K
            cnt_passenger = 1
            cnt_bus += 1
    print(cnt_bus)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

t = sorted(t)

cnt = 1
cap = 1

for i in range(1, n):
    if t[i] > t[i-1] + k:
        cnt += 1
        cap = 1
    elif cap == c:
        cnt += 1
        cap = 1
    else:
        cap += 1

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect
import sys

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

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

Submission status: Wrong Answer

Solution code:
import bisect

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

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

Submission status: Wrong Answer

Solution code:
N,C,K = map(int,input().split())
A = []
for i in range(N):
  temp = int(input())
  A.append(temp)
A.sort()
ans = 1
nxt = A[0]+K
cus = 0
for i in range(N):
  if A[i] <= nxt and cus < C:
    cus +=1
    continue
  else:
    nxt = A[i]+K
    cus = 0
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])[::-1]
# print(f'{T=}')

ans = 1
cnt = 1
time = T[0]
for t in T[1:]:
    # print(f'{ans=}, {cnt=}, {time=}, {t=}')
    if t + K < time:
        cnt = 1
        ans += 1
        time = t
        continue
    if cnt == C:
        cnt = 1
        ans += 1
    else:
        cnt += 1
print(ans)

Submission status: Wrong Answer

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

#Ti以上Ti+k以下のバスに乗る
#定員はC人

T = [i+k for i in t]

cnt = 0
bus = 0
x = 0
for i in range(n):
    cnt += 1
    if x==0: x = T[i]
    if x < t[i]:
        cnt = 1
        x = T[i]
        bus += 1
    if cnt == c:
        cnt == 0
        x = 0
        bus += 1
    x = max(x, T[i])
print(bus if cnt==0 else bus+1)

Submission status: Wrong Answer

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

#Ti以上Ti+k以下のバスに乗る
#定員はC人

T = [i+k for i in t]

cnt = 0
bus = 0
x = 0
for i in range(n):
    cnt += 1
    if x==0: x = T[i]
    if x < t[i] or cnt == c:
        bus += 1
        x = T[i]
        if x < t[i]:cnt = 1
        else: cnt == 0
print(bus+1 if cnt >= 1 else bus)

Submission status: Wrong Answer

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

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

while i<N:
    lim = T[i]+K
    ans += 1
    cnt = 0
    
    while i<N and cnt<C and T[i]<lim:
        i += 1
        cnt += 1
        
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# input
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
t.sort()
ans = 1
now = t[0]
cnt = 1
for i in range(n):
    if t[i] - now > k or cnt > c:
        now = t[i]
        cnt = 1
        ans += 1
    else:
        cnt += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# input
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
t.sort()
ans = 1
now = t[0]
cnt = 1
for i in range(n):
    if t[i] - now > k or cnt > c:
        plus_bit = 1
        now = t[i]
        cnt = 1
        ans += 1
    else:
        cnt += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, C, K = mapint()

Ts = [int(input()) for _ in range(N)]
Ts.sort()
last_cus = Ts[0]
cum = 1
bus = 0
for i in range(1, N):
    t = Ts[i]
    if t-last_cus>K:
        bus += 1
        cum = 0
    cum += 1
    last_cus = t
    if cum==C:
        bus += 1
        cum = 0
        last_cus = 10**18
if cum!=0:
    print(bus+1)
else:
    print(bus)

Submission status: Wrong Answer

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

nw = T[0]
bs = 1
ans = 1
for i in range(1, N):
    t = T[i]
    if bs == C:
        bs = 0
        nw = t
        ans += 1
    elif t-nw > K:
        bs = 0
        nw = t
        ans += 1
    else:
        bs += 1
else:
    if bs > 0:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

nw = T[0]
bs = 1
ans = 1
for i in range(1, N):
    t = T[i]
    if bs == C:
        bs = 0
        nw = t
        ans += 1
    elif t-nw > K:
        bs = 0
        nw = t
        ans += 1
    else:
        bs += 1

print(ans)

Submission status: Wrong Answer

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

nw = T[0]
bs = 1
ans = 1
for i in range(1, N):
    t = T[i]
    if bs < C and t-nw <= K:
        bs += 1
    else:
        ans += 1
        nw = t
        bs = 0

print(ans)

Submission status: Wrong Answer

Solution code:
N,C,K=map(int,input().split())
T=[int(input()) for i in range(N)]
T.sort()
res=0
num=0
while num<N:
    for i in range(num,min([num+C,N])):
        if T[i]>T[num]+K:
            num=i
            res+=1
            break
    num+=C
    res+=1

print(res)

Submission status: Wrong Answer

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

end = tl[0] + k
passenger_cnt = 1
bus_cnt = 0
for i in range(1,n):
    # 間に合う場合
    if end >= tl[i]:
        passenger_cnt += 1
        if i == n-1:
            if passenger_cnt <= c:
                bus_cnt += 1
                break
            else:
                bus_cnt += 2
                break
        elif passenger_cnt == c:
            bus_cnt += 1
            passenger_cnt = 0
            end = tl[i+1]+k

    # 間に合わない場合
    else:
        if i == n-1:
            bus_cnt += 2
            break
        bus_cnt += 1
        end = tl[i] + k
        passenger_cnt = 1

print(bus_cnt)

Submission status: Wrong Answer

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

end = tl[0] + k
passenger_cnt = 1
bus_cnt = 0
for i in range(1,n):
    # 間に合う場合
    if end >= tl[i]:
        passenger_cnt += 1
        if i == n-1:
            bus_cnt += 1
            break
        elif passenger_cnt == c:
            bus_cnt += 1
            passenger_cnt = 0
            end = tl[i+1]+k
    
    # 間に合わない場合
    else:
        if i == n-1:
            bus_cnt += 2
            break
        bus_cnt += 1
        end = tl[i] + k
        passenger_cnt = 1

print(bus_cnt)

Submission status: Wrong Answer

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

end = tl[0] + k
passenger_cnt = 1
bus_cnt = 0
for i in range(1,n):
    if end >= tl[i]:
        passenger_cnt += 1
        if i == n-1:
            bus_cnt += 1
            break
        elif passenger_cnt == c:
            bus_cnt += 1
            passenger_cnt = 0
            end = tl[i+1]+k
    else:
        if i == n-1:
            bus_cnt += 2
            break
        bus_cnt += 1
        end = tl[i+1] + k
        passenger_cnt = 1

print(bus_cnt)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int, input().split())
t=[int(input()) for _ in range(n)]
t.sort()
tmp_lim=t[0]+k
num_bus=0
num_person=1
for i in range(1, n):
    if tmp_lim<t[i] or c<=num_person:
        num_bus+=1
        tmp_lim=t[i]+k
        num_person=1
    else:
        num_person+=1
    print(num_bus, num_person, tmp_lim)
print(num_bus+1)

Submission status: Wrong Answer

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

ans = 0
cnt = 0
tmp_t = 0
for t in arr:
    if cnt == 0:
        tmp_t = t
    cnt += 1
    if cnt >= c:
        ans += 1
        cnt = 0
    elif t - tmp_t > k:
        ans += 1
        cnt = 1
        tmp_t = t
if cnt:
    ans += 1

print(ans)

Submission status: Wrong Answer

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

ans = 0
cnt = 0
tmp_t = 0
for t in arr:
    cnt += 1
    if cnt >= c:
        ans += 1
        cnt = 0
    elif t - tmp_t > k:
        ans += 1
        cnt = 1
        tmp_t = t

print(ans)

Submission status: Wrong Answer

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

ans = 0
cnt = 0
tmp_t = 0
for t in arr:
    cnt += 1
    if cnt >= c:
        ans += 1
        cnt = 0
    elif t - tmp_t > k:
        ans += 1
        cnt = 0
        tmp_t = t

print(ans)

Submission status: Wrong Answer

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

ans = 0
cnt = 0
tmp_t = 0
for t in arr:
    cnt += 1
    if cnt >= c:
        ans += 1
        cnt = 0
    elif t - tmp_t > k:
        ans += 1
        tmp_t = t

print(ans)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
cnt = 0
ans = 0
t_l = []
for _ in range(n):
    t_l.append(int(input()))
t_l.sort()

for t in t_l:
    if cnt == 0:
        t1 = t
    if t <= t1 + k:
        cnt += 1
        if cnt == 3:
            cnt = 0
            ans += 1
    else:
        cnt = 1
        ans += 1
        t1 = t
if cnt != 0:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, C, K = LI()
    T = [I() for _ in range(N)]
    T.sort()

    t = T[0]
    cnt = 0
    ans = 0
    for i in T:
        cnt += 1
        if cnt > C or i > t + K:
            ans += 1
            cnt = 0
            t = i
    ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, C, K = LI()
    T = [I() for _ in range(N)]
    T.sort()

    # TiからTi+K分の間の人をバスに乗せる
    t = 0
    cnt = 0
    ans = 0
    for i in T:
        cnt += 1
        if i > t + K:
            ans += (cnt - 1) // C + 1
            cnt = 0
            t = i

    print(ans)

if __name__ == '__main__':
    resolve()