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 = [int(x) for x in input().split()]
t = []
for _ in range(n):
    t.append(int(input()))
t.sort()

ans = 0
tmp = {"f": 0, "num": 0}

for x in t:
    if x - tmp["f"] >= k or tmp["num"] >= c:
        ans += 1
        tmp["f"] = 0
        tmp["num"] = 0
    if tmp["f"] == 0:
        tmp["f"] = x
    tmp["num"] += 1

if tmp["num"] != 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = [int(x) for x in input().split()]
t = []
for _ in range(n):
    t.append(int(input()))
t.sort()

ans = 0
tmp = {"f": 0, "num": 0}

for x in t:
    if x - tmp["f"] >= k or tmp["num"] == c:
        ans += 1
        tmp["f"] = 0
        tmp["num"] = 0
    if tmp["f"] == 0:
        tmp["f"] = x
    tmp["num"] += 1

if tmp["num"] != 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
T = [0]*N
cnt = 1
bus = 1
for i in range(N):
    T[i] = int(input())
T.sort()
tmp = T[0]+K
for i in range(1, N):
    if(cnt == 0):
        bus += 1
        cnt = 1
        tmp = T[i]+K
        
    if(T[i] <= tmp and cnt < C):
        cnt += 1
        if(cnt == C):
            cnt = 0
    else:
        cnt = 1
        bus += 1
        tmp = T[i]+K
print(bus)

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
T = [0]*N
cnt = 1
bus = 1
for i in range(N):
    T[i] = int(input())
T.sort()
tmp = T[0]+K
for i in range(1, N):
    if(cnt == 0):
        tmp = T[i]+K
        bus += 1
        cnt += 1
        
    if(T[i] <= tmp):
        cnt += 1
        if(cnt == C):
            cnt = 0
    else:
        cnt = 1
        tmp = T[i]+K
        bus += 1     
print(bus)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
  t[i]=int(input())
t=sorted(t)

ans=1
cnt=0
time=t[0]+k

for i in range(n):
  if cnt>=c or time<t[i]:
    cnt=0
    ans+=1
    time=t[i]+k
  else:
    cnt+=1
    
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
  t[i]=int(input())
t=sorted(t)

ans=1
cnt=0
time=t[0]+k

for i in range(n):
  if cnt==c or time<t[i]:
    cnt=0
    ans+=1
    time=t[i]+k
  else:
    cnt+=1
    
print(ans)

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
T = [0]*N
cnt = 0
bus = 0
for i in range(N):
    T[i] = int(input())
T.sort()
    
tmp = T[0]+K
for i in range(N):
    if(T[i] <= tmp):
        cnt += 1
        if(cnt == C):
            bus += 1
            tmp = T[min(i+1, N-1)]+K
            cnt = 0
    else:
        bus += 2
        tmp = T[i]+K
        cnt = 0
print(bus)

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
Tlist = sorted([int(input()) for _ in range(N)])
ans = 0
now = 1
start = Tlist[0]
for t in Tlist:
    if now == C:
        ans += 1
        start = t
        now = 1
    else:
        if t - start <= K:
            now += 1
        else:
            ans += 1
            start = t
            now = 1
print(ans+1)

Submission status: Wrong Answer

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

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

t_list.sort()
#print(t_list)

ans = 1
tmp = 0
pass_list = []
for t in t_list:
    #print(t)
    #print(pass_list)
    # 最初の乗客
    if len(pass_list) == 0:
        # 一番古い乗客の時間をメモ
        tmp = t
        # バスに乗せる
        pass_list.append(t)
    
    else:
        # 一番古い乗客の待ち時間が長い場合新しいバスを用意して乗せる
        if (t - tmp) > k:
            pass_list = []
            #print('バス追加1')
            ans += 1
            # 一番古い乗客の時間をメモ
            tmp = t

            pass_list.append(t)

        # バスに乗せる
        else:
            pass_list.append(t)

    # バスの定員が一杯の場合も新しいバスを用意する
    if len(pass_list) == c:
        pass_list = []
        #print('バス追加2')
        ans += 1

print(ans)

Submission status: Wrong Answer

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

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

t_list.sort()
#print(t_list)

ans = 1
tmp = 0
pass_list = []
for t in t_list:
    #print(t)
    #print(pass_list)
    # 最初の乗客
    if tmp == 0:
        # 一番古い乗客の時間をメモ
        tmp = t
        # バスに乗せる
        pass_list.append(t)
        continue
    
    if len(pass_list) < c:
        # 一番古い乗客の待ち時間が長い場合新しいバスを用意して乗せる
        if t - tmp > k:
            pass_list = []
            #print('バス追加1')
            ans += 1
            # 一番古い乗客の時間をメモ
            tmp = t

            pass_list.append(t)

        # バスに乗せる
        else:
            pass_list.append(t)

    # バスの定員が一杯の場合も新しいバスを用意する
    elif len(pass_list) == c:
        pass_list = []
        #print('バス追加2')
        ans += 1
        # 一番古い乗客の時間をメモ
        tmp = t

print(ans)

Submission status: Wrong Answer

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

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

t_list.sort()
#print(t_list)

ans = 0
tmp = 0
pass_list = []
for t in t_list:
    #print(t)
    #print(pass_list)
    if tmp == 0:
        # 一番古い乗客の時間をメモ
        tmp = t
        # バスに乗せる
        pass_list.append(t)
        continue
    
    if len(pass_list) < c:
        # 一番古い乗客の待ち時間が長い場合新しいバスを用意して乗せる
        if t - tmp > k:
            pass_list = []
            #print('バス追加1')
            ans += 1
            # 一番古い乗客の時間をメモ
            tmp = t

            pass_list.append(t)

        # バスに乗せる
        else:
            pass_list.append(t)

    # バスの店員が一杯の場合も新しいバスを用意する
    elif len(pass_list) == c:
        pass_list = []
        #print('バス追加2')
        ans += 1
        # 一番古い乗客の時間をメモ
        tmp = t

ans += 1
print(ans)

Submission status: Wrong Answer

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

t.sort()
for i in range(len(t)):
  cnt = 1
  for _ in range(i+1, len(t)):
    if t[i+1] - t[i] <= k:
      cnt += 1
      t.remove(t[i+1])
      if cnt == c:
        break
    else:
      break
      
      
print(len(t))

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=1
mem=1
s=T[0]

for i in range(N):
    if T[i]>s+K or mem>=C:
        ans+=1
        s=T[i]
        mem=1
    else:
        mem+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, c, k = map(int, readline().split())
t = [int(readline()) for i in range(n)]
t.sort()
cnt = 0
ans = 1
for i in range(n):
    cnt += 1
    if cnt == 1:
        time = t[i] + k
    if cnt >= c or time < t[i]:
        ans += 1
        cnt = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, c, k = map(int, readline().split())
t = [int(readline()) for i in range(n)]
t.sort()
cnt = 0
time = float('inf')
ans = 1
for tt in t:
    if cnt < (c - 1) and time > tt:
        if cnt == 0:
            time = tt + k
        cnt += 1
    else:
        cnt = 0
        time = float('inf')
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n, c, k, *t = map(int, open(0).read().split())
    t = sorted(t)
    u = tuple(t)

    cnt = 1
    p, l = 0, u[0] + k
    for v in t:
        if v <= l and p < c:
            p += 1
        else:
            cnt += 1
            l = v + k
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, c, k, *t = map(int, open(0).read().split())
    t = sorted(t)
    u = tuple(t)

    count = 1
    i = 0
    p = 1
    lim = u[i] + k
    while i < n:
        if u[i] <= lim and p < c:
            i += 1
            p += 1
        else:
            count += 1
            lim = u[i] + k
            p = 1
    print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, c, k, *t = map(int, open(0).read().split())
    t = sorted(t)
    u = tuple(t)

    count = 1
    i = 0
    p = 1
    lim = u[i] + k
    while i < n:
        if u[i] <= lim or p < c:
            i += 1
            p += 1
        else:
            count += 1
            lim = u[i] + k
            p = 1
    print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
T = [0] * N
for i in range(N):
  T[i] = int(input())
T = sorted(T)
ans = 0
waiting = []
for t in T:
  if len(waiting) == C:
    ans += 1
    waiting = []
  elif len(waiting) > 0 and t > waiting[0] + K:
    ans += 1
    waiting = []
  else:
    waiting.append(t)
else:
  ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

# print(N, C, K)
# print(*T, end="\n")

# 現在の時刻
count = 0
i = 0
while i < N:
    ti = T[i]
    timax = ti + K
    while i < N and T[i] < timax:
        i += 1
    count += 1
print(count)

Submission status: Wrong Answer

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

t.sort()

diff = 0
cnt = 0
ans = 0
for i in range(n - 1):
    if abs(t[i + 1] - t[i]) == 0:
        cnt += 1
        if cnt >= c:
            cnt = 0
            diff = 0
            ans += 1
    else:
        diff += abs(t[i + 1] - t[i])
        cnt += 1
        if diff >= k or cnt >= c:
            cnt = 0
            diff = 0
            ans += 1
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()

diff = 0
cnt = 0
ans = 0
for i in range(n - 1):
    if abs(t[i + 1] - t[i]) == 0:
        cnt += 1
        if cnt > c:
            cnt = 0
            diff = 0
            ans += 1
    else:
        diff += abs(t[i + 1] - t[i])
        cnt += 1
        if diff >= k or cnt > c:
            cnt = 0
            diff = 0
            ans += 1
print(ans + 1)

Submission status: Wrong Answer

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

t.sort()

for i in t:
    if lastbus[0] <= i:
        ans += 1
        lastbus[0] = i+c
        lastbus[1] = c-1
    else:
        if lastbus[1] == 0:
            ans += 1
            lastbus[0] = i+c
            lastbus[1] = c-1
        else:
            lastbus[1] -= 1
print(ans)

Submission status: Wrong Answer

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

t.sort()
for i in t:
    if lastbus[0] < i:
        ans += 1
        lastbus[0] = i+c
        lastbus[1] = c-1
    else:
        if lastbus[1] == 0:
            ans += 1
            lastbus[0] = i+c
            lastbus[1] = c-1
        else:
            lastbus[1] -= 1
print(ans)

Submission status: Wrong Answer

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

for t in T:
    if t>base+K or count>C:
        answer+=1
        base=t
        count=1
    else:
        count+=1

answer+=1

print(answer)

Submission status: Wrong Answer

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

ans = 1

time = -1
for i,t in enumerate(T):
    if time < 0:
        cnt, time = 1, t + K
    elif t <= time:
        cnt += 1
    else:
        ans += 1
        cnt, time = 1, t + K
    
    if cnt == C:
        time = -1
        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.sort()
count = 0
ans = 0
time = 0
for t in T:
  if count == 0:
    time = t
  if time +k < t:
    count = 0
    time = t
    ans += 1
  count += 1
  if count == c:
    ans += 1
    count = 0
    continue
else:
  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)])
ans, cnt = 0, 0
st = T[0]
for i in range(N):
  if T[i] <= st + K:
    cnt += 1
    if cnt == C:
      ans += 1
      st = T[min(i+1,N-1)]
  else:
    ans += 1
    cnt = 0
    st = T[i]
print(ans+1)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int, input().split())
a = []
bus = 1
for i in range(n):
  a.append(int(input()))
a.sort()
j = 0
count = 1
while j + count in range(n):
  if a[j+count] < a[j] + k and count < c:
    count = count + 1
  else:
    bus = bus + 1
    j = j + count
    count = 1
print(bus)

Submission status: Wrong Answer

Solution code:
def main():
    n, c, k = map(int, input().split())
    t = [None]*n
    for i in range(n):
        t[i] = int(input())
    t.sort()
    ans = 0
    l = 0
    x = -1
    for r in range(1, n):
        if x < t[r] or c < r-l+1:
            ans += 1
            l = r
            x = t[r] + k
        if r == n-1:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

min_t = 0
i = 0
while i < N:
    ans += 1
    start = i
    while i < N and T[i] - T[start] < K and i - start < C:
        i += 1
print(ans)

Submission status: Wrong Answer

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

def init_bus():
    global bus, min_t, ans
    bus = []
    bus.append(t)
    min_t = t
    ans += 1

min_t = 0
for t in T:
    if len(bus) == 0:
        init_bus()
        continue
    if t - min_t < K and len(bus) < C:
        bus.append(t)
    else:
        init_bus()
print(ans)

Submission status: Wrong Answer

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

def init_bus():
    global bus, min_t, ans
    bus = []
    bus.append(t)
    min_t = t
    ans += 1

min_t = 0
for t in T:
    if len(bus) == 0:
        init_bus()
        continue
    if t - min_t < K and len(bus) < C:
        bus.append(t)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
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:
        len_t += 1
    else:
        ans1 += math.ceil(len_t/c)
        key = t[i]+k
        len_t = 1
ans1 += math.ceil(len_t/c)

t.sort(reverse=True)
key = t[0]-k
len_t = 0
ans2 = 0
for i in range(n):
    if t[i] >= key:
        len_t += 1
    else:
        ans2 += math.ceil(len_t/c)
        key = t[i]-k
        len_t = 1
ans2 += math.ceil(len_t/c)
print(min(ans1,ans2))

Submission status: Wrong Answer

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

t.sort(reverse=True)
key = t[0]-k
len_t = 0
ans = 0
for i in range(n):
    if t[i] >= key:
        len_t += 1
    else:
        ans += math.ceil(len_t/c)
        key = t[i]-k
        len_t = 1
ans += math.ceil(len_t/c)
print(ans)

Submission status: Wrong Answer

Solution code:
n, c, k = [int(e) for e in input().split()]# 5 3 5
t = [] # 1 2 3 6 12
bus_count = 0
time_diff = 0
stock = 0
first_customer_arrival_time = 0
i = 0

for _ in range(n):
    t.append(int(input()))
t.sort()
while i < n-1:
    # First customer
    if stock == 0:
        first_customer_arrival_time = t[i]
        stock = 1
    else:
        stock += 1
    time_diff = t[i+1] - first_customer_arrival_time
    # Timeout or Full
    if time_diff >= k or stock == c:
        bus_count += 1
        stock = 0
        time_diff = 0 
    i += 1
# Lastbus
bus_count += 1
print(bus_count)

Submission status: Wrong Answer

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

time = 0
limit = st[0]+k

d = {}
d[limit] = []

for i, p in enumerate(st):
  if p <= limit and len(d[limit]) < c:
    d[limit].append(p)
  else:
    limit = p + k
    d[limit] = [p]

print(len(d))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
T = [0]*n
for i in range(n):
    T[i] = int(input())
T.sort()
ans = 1
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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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:
        ans += 1
        jk = 0
    if mx>k:
        ans += 1
        mx = 0
        jk = 0 
print(ans if jk==0 else ans+1)

Submission status: Wrong Answer

Solution code:
from sys import stdin

def main():
    input = stdin.readline

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

    T = [0] * N

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

    T.sort()

    bus_num = 1
    jyokyaku = 1
    bus_start = T[0]

    for i in range(1,N):
        jyokyaku = jyokyaku + 1
        # jyokyakuが乗れる人数を超えると新しいバスを用意
        if(C < jyokyaku):
            bus_num = bus_num + 1
            bus_start = T[i]
        elif(T[i] - bus_start > K):
            bus_num = bus_num + 1
            bus_start = T[i]

    
    print(bus_num)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

cnt = 0
ans = 0
lst = [int(input()) for _ in range(N)]
lst = sorted(lst)
next_t = 10**10
for t in lst:
  next_t = min(t+K,next_t)
  if (t > next_t):
    ans += 1
    cnt = 0
    next_t = 10**10
    
  cnt += 1
  if (cnt == C):
    ans += 1
    cnt = 0
    next_t = 10**10
    
if (cnt > 0):
  ans += 1
print(ans)

Submission status: Wrong Answer

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

cnt = 0
ans = 0
lst = [int(input()) for _ in range(N)]
lst = sorted(lst)
next_t = 10**10
for t in lst:
  next_t = min(t+K,next_t)
  if (t >= next_t):
    ans += 1
    cnt = 0
    next_t = 10**10
    
  cnt += 1
  if (cnt == C):
    ans += 1
    cnt = 0
    next_t = 10**10
    
if (cnt > 0):
  ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n, c, k = (int(x) for x in input().split())
t = []
for _ in range(n): t.append(int(input()))
t.sort()
a = 0
while len(t) != 0:
    t_ = t[0]
    c_ = idx = 0
    for i in range(len(t)):
        if t[i] - t_ > k or c_ == c:
            a += 1
            idx = i
            break
        elif i == len(t) - 1:
            a += 1
            idx = 1
            break
        else: c_ += 1
    for _ in range(idx):
        t.pop(0)
print(a)

Submission status: Wrong Answer

Solution code:
# AGC 011 A - Airport Bus
#time limitは一番待たされている客基準⇒sortの先頭
N,C,K = map(int,input().split())
T = [int(input()) for __ in range(N)]

ans = 1 #最低1台はバスが出る
count = 0 #乗客の数をカウント,最大C人まで
T.sort()
ts = T[0] #一番待たされている客の到着時間

#print(T)
for t in T:
    if t-ts > K:
        ans += 1 #バス追加
        ts = t #次の客の待ち時間
        count = 1 #乗客数リセット
    else:
        count += 1 #乗客+1
    if count == C: #乗客がいっぱいになったら
        ans += 1 #バス追加
        ts = t #次の客の待ち時間
        count = 1 #乗客数リセット
print(ans)

Submission status: Wrong Answer

Solution code:
# AGC 011 A - Airport Bus
#time limitは一番待たされている客基準⇒sortの先頭
N,C,K = map(int,input().split())
T = [int(input()) for __ in range(N)]

ans = 1 #最低1台はバスが出る
count = 0 #乗客の数をカウント,最大C人まで
ts = T[0] #一番待たされている客の到着時間
T.sort()
for t in T:
    if t-ts > K:
        ans += 1 #バス追加
        ts = t #次の客の待ち時間
        count = 1 #乗客数リセット
    else:
        count += 1 #乗客+1
    if count == C: #乗客がいっぱいになったら
        ans += 1 #バス追加
        ts = t #次の客の待ち時間
        count = 1 #乗客数リセット
print(ans)

Submission status: Wrong Answer

Solution code:
# AGC 011 A - Airport Bus
#time limitは一番待たされている客基準⇒sortの先頭
N,C,K = map(int,input().split())
T = [int(input()) for __ in range(N)]

ans = 1 #最低1台はバスが出る
count = 0 #乗客の数をカウント,最大C人まで
ts = T[0] #一番待たされている客の到着時間
T.sort()
for t in T:
    if t-ts > K:
        ans += 1 #バス追加
        ts = t #次の客の待ち時間
        count = 0 #乗客数リセット
    else:
        count += 1 #乗客+1
    if count == C: #乗客がいっぱいになったら
        ans += 1 #バス追加
        ts = t #次の客の待ち時間
        count = 0 #乗客数リセット
print(ans)

Submission status: Wrong Answer

Solution code:
# AGC 011 A - Airport Bus
#time limitは一番待たされている客基準⇒sortの先頭
N,C,K = map(int,input().split())
T = [int(input()) for __ in range(N)]

ans = 1 #最低1台はバスが出る
count = 0 #乗客の数をカウント,最大C人まで
ts = T[0] #一番待たされている客の到着時間
for t in T:
    if t-ts > K:
        ans += 1 #バス追加
        ts = t #次の客の待ち時間
        count = 0 #乗客数リセット
    else:
        count += 1 #乗客+1
    if count == C: #乗客がいっぱいになったら
        ans += 1 #バス追加
        ts = t #次の客の待ち時間
        count = 0 #乗客数リセット
print(ans)

Submission status: Wrong Answer

Solution code:
# AGC 011 A - Airport Bus
#time limitは一番待たされている客基準⇒sortの先頭
N,C,K = map(int,input().split())
T = [int(input()) for __ in range(N)]

ans = 1 #最低1台はバスが出る
count = 0 #乗客の数をカウント,最大C人まで
ts = T[0] #一番待たされている客の到着時間
for t in T:
    if t-ts > K:
        ans += 1 #バス追加
        ts = t #次の客の待ち時間
        count = 0 #乗客数リセット
    else:
        count += 1 #乗客+1
    if count == C: #乗客がいっぱいになったら
        ans += 1 #バス追加
        ts = t #次の客の待ち時間
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

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

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

        if len(passengers) == C:
            ans += 1
            passengers = []
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

if __name__ == '__main__':
    main()