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(reverse=True)

bus=0
arr=0
que=0
for i in range(n):
  tt=t[i]
  if que==0:
    arr=tt
    que+=1
  else:
    if que==c:
      bus+=1
      arr=tt
      que=1
    else:
      if arr+k>tt:
        bus+=1
        arr=tt
        que=1
      else:
        que+=1
print(bus)

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

bus=0
arr=0
que=0
for i in range(n):
  tt=t[i]
  if que==0:
    print('que=0,i,bus,arr,que,t[i]',i,bus,arr,que,t[i])
    arr=tt
    que+=1
    bus+=1
  else:
    if que==c:
      #print('q==c,i,bus,arr,que,t[i]',i,bus,arr,que,t[i])
      bus+=1
      arr=tt
      que=1
    else:
      if arr+k<tt:
        #print('dep,i,bus,arr,que,t[i]',i,bus,arr,que,t[i])
        bus+=1
        arr=tt
        que=1
      else:
        
        que+=1

print(bus)

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

bus=0
arr=0
que=0
for i in range(n):
  tt=t[i]
  if que==0:
    arr=tt
    que+=1
  else:
    if que==c:
      bus+=1
      arr=tt
      que=0
    else:
      if arr+k>tt:
        bus+=1
        arr=tt
        que=0
print(bus)

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

bus=0
arr=0
que=0
for i in range(n):
  tt=t[i]
  if que==0:
    arr=tt
    que+=1
  else:
    if arr+k>tt:
      bus+=1
      arr=tt
      que=0
print(bus)

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

bus=0
arr=0
que=0
for i in range(n):
  tt=t[i]
  if que==0:
    arr=tt
    que+=1
  else:
    if que==c:
      bus+=1
      arr=tt
      que=1
    else:
      if arr+k>tt:
        bus+=1
        arr=tt
        que=1
print(bus)

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

bus=0
arr=0
que=0
for i in range(n):
  tt=t[i]
  if que==0:
    #print('que=0,i,bus,arr,que,t[i]',i,bus,arr,que,t[i])
    arr=tt
    que+=1
    bus+=1
  else:
    if que==c:
      #print('q==c,i,bus,arr,que,t[i]',i,bus,arr,que,t[i])
      bus+=1
      arr=tt
      que=1
    else:
      if arr+k<tt:
        #print('dep,i,bus,arr,que,t[i]',i,bus,arr,que,t[i])
        bus+=1
        arr=tt
        que=1
      else:
        
        que+=1

print(bus)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted