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

peo = 0
bus = 1
out = T[0] + k

for t in T:
    peo += 1
    if t <= out and peo < c:
        continue
    else:
        out = t + k
        peo = 0
        bus += 1

print(bus)

Submission status: Wrong Answer

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

peo = 0
bus = 1
out = T[0] + k

for t in T:
    peo += 1
    if t <= out and peo <= c:
        continue
    else:
        out = t + k
        peo = 0
        bus += 1

print(bus)

Submission status: Wrong Answer

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

cnt = 0
ans = 1
x = T[0] + k

for t in T:
    cnt += 1

    if t > x:
        cnt = 0
        ans += 1
        x = t + k
         
    elif cnt > c:
        cnt = 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)])

cont = 0
ans = 1

x = T[0] + k

for t in T:
    cont += 1
    if t > x:
        ans += 1
        x = t + k
    elif cont > c:
        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)])
s, c = 0, C
ans = 1
for t in T:
    if t <= s + K and c:
        c -= 1
    else:
        s = t
        c = C - 1
        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)])
s, c = 0, C
ans = 1
for t in T:
    if t <= s + K and c:
        c -= 1
    else:
        s = t
        c = C
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
# 乗せれるだけ乗っけるのがいいと思うだけなんだけどどうなんでしょう
n, c, k = map(int, input().split())
ans = 0
arr = sorted([int(input()) for _ in range(n)])
l, r = 0, 0
cur = arr[r]
limit = cur + c
tmp = 0
while r < n:
    # print("limit {}".format(limit))
    while r < n and tmp < c and cur <= limit:
        tmp += 1
        r += 1
        if r >= n:
            break
        cur = arr[r]
    # print("{}までに{}人乗せた".format(r, tmp))
    limit = cur + c
    tmp = 0
    ans += 1
    # print(ans)

if tmp > 0:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
# 乗せれるだけ乗っけるのがいいと思うだけなんだけどどうなんでしょう
n, c, k = map(int, input().split())
ans = 1
arr = sorted([int(input()) for _ in range(n)])
idx = 0
cur_n, cur_t = 0, 0
first = True
cur_limit = k
while idx < n:
    if cur_n == c:
        ans += 1
        cur_limit = arr[idx] + k
        cur_t = arr[idx]
        cur_n = 0
        idx += 1
        first = True
        continue
    if cur_t > cur_limit:
        ans += 1
        cur_limit = arr[idx] + k
        cur_t = arr[idx]
        cur_n = 0
        first = True
        idx += 1
        continue
    if first:
        first = False
        cur_t = arr[idx]
        cur_limit = arr[idx] + k
        cur_n = 1
        idx += 1
    else:
        cur_n += 1
        cur_t += arr[idx]
        idx += 1
if cur_n > 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)])
count = 0
ans = 0
for t in T:
    if count == 0:
        count = 1
        flag = t + K
    else:
        if t <= flag:
            count += 1
            if count == C:
                ans += 1
                count = 0
                if t == T[-1]:
                    ans -= 1
        else:
            ans += 1
            count = 1
            flag = t + K
        

print(ans+1)

Submission status: Wrong Answer

Solution code:
N, C, K = map(int,input().split())
T = [int(input()) for _ in range(N)]
count = 0
ans = 0
for t in T:
    if count == 0:
        count = 1
        flag = t
    else:
        if t <= flag+K:
            count += 1
        else:
            ans += 1
            count = 1
            flag = t
        if count+1 == C:
            ans += 1
            count = 0
            if t == T[-1]:
                ans -= 1

print(ans+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
time = 0
people = 1
ans = 1
for t in T:
    if t <= time + K and people < C:
        people += 1
    else:
        time = t
        people = 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()
time = T.pop(0)
people = 1
ans = 1
for t in T:
    if t <= time + K and people < C:
        people += 1
    else:
        time = t
        people = 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.sort()
time = T.pop(0)+K
people = 1
ans = 1
for t in T:
    if t <= time and people < C:
        people += 1
    else:
        if people == C:
            time += t
        else:
            time += K
        people = 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.sort()
time = T.pop(0)+K
people = 1
ans = 1
for t in T:
    if t <= time and people < C:
        people += 1
    else:
        time += K
        people = 0
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int, input().split())
l=[int(input()) for x in range(n)]
l.sort()
flg=0
bus=0
capa=0
for i in range(n):
    if capa<c:
        if l[i]<=flg+k:
            capa+=1
        else:
            bus+=1
            flg=l[i]
            capa=0
    elif capa==c:
        bus+=1
        capa=0
    
print(bus+1)

Submission status: Wrong Answer

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

t = sorted([int(input()) for i in range(n)])

count = 1
bus = 1
start = t[0]
for i in range(1, n):
    if count == 3:
        start = t[i]
        count = 1
        bus += 1
        
    elif start <= t[i] <= start + k:
        count += 1
    else:
        start = t[i]
        bus += 1
        count = 1

print(bus)

Submission status: Wrong Answer

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

bus = []
cnt = 0

for t in T:
    if bus == []:
        tle = t + k
    if t > tle:
        bus = []
        cnt += 1
        tle = 10**9+k

    bus.append(t)

    if len(bus) == c:
        bus = []
        cnt += 1
        tle = 10**9+k

if bus != []:
    print(cnt+1)
else:
    print(cnt)

Submission status: Wrong Answer

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

bus = []
cnt = 0

for t in T:
    if bus == []:
        tle = t + k
    if t > tle:
        bus = []
        cnt += 1
        tle = 10**9+k

    bus.append(t)

    if len(bus) == 3:
        bus = []
        cnt += 1
        tle = 10**9+k

if bus != []:
    print(cnt+1)
else:
    print(cnt)

Submission status: Wrong Answer

Solution code:
n,c,k= map(int,input().split())
t=sorted([int(input()) for i in range(n)])
cnt=1
lim=1
ti=t[0]
for i in range(n):
	if ti+k<t[i] or lim>c:
		ti=t[i]
		cnt+=1
		lim=1
	else:
		lim+=1
	
print(cnt)

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()
count = 0
time = T[0] + K
ppl = 1
for i in range(1,N):
    flag = True
    ppl += 1
    if T[i] > time:
        count += 1
        time = T[i]+K
        ppl = 1
        flag = False
    if ppl == C:
        count += 1
        if i != N-1:
            time = T[i+1]+K
        ppl = 0
        flag = False
    if i == N-1 and flag:
        count += 1
print(count)

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()
count = 1
time = T[0] + K
ppl = 0
for i in T:
    ppl += 1
    if i > time or ppl == C:
        count += 1
        time = i+K
        ppl = 0
print(count)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
n,c,k=map(int,input().split())
a=[int(input()) for i in range(n)]
a.sort()
ans=0
cnt=[0,0]
for i in range(n):
  if cnt[0]==c:
    ans+=1
    cnt[0]=1
    cnt[1]=a[i]
  elif a[i]-cnt[1]>k:
    ans+=1
    cnt[0]=1
    cnt[1]=a[i]
  else:
    cnt[0]+=1
if cnt[0]>=1:
  ans+=1
print(ans)

Submission status: Wrong Answer

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

total_bus = 1
bus = 1
for i in range(1, n):
    if passenger[i] > passenger[i-1] + k:
        bus = 0
        total_bus += 1
    else:
        if bus == c:
            total_bus += 1
            bus = 0
    bus += 1

print(total_bus)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, C, K = map(int, input().split(' '))
T = sorted([int(input()) for _ in range(N)])

ans = 1
c, n = 0, T[0] + K
for i in range(N):
    if c == C:
        c = 0
        ans += 1
        n = T[i] + K

    else:
        if T[i] < n:
            c += 1
        else:
            n = T[i] + K
            ans += 1
            c = 0

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, C, K = map(int, input().split(' '))
T = sorted([int(input()) for _ in range(N)])

ans = 1
c, n = 0, T[0]
for i in range(N):
    if c == C:
        c = 0
        ans += 1
        n = T[i]

    else:
        if n <= T[i] <= n + K:
            c += 1
        else:
            n = T[i]
            ans += 1
            c = 0

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
from math import ceil
N, C, K = map(int, input().split())
T = []
for _ in range(N):
    t = int(input())
    T.append(t)
T.sort()
ans = 0
time = 0
l = []
for i in range(N):
    l.append(T[i])
    if len(l) >= C or (l[-1] - l[0]) >= K:
        ans += ceil((i+1) / C)
        l = []
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(reverse=True)
bus = 1 
c = 2 
j = T.pop() 
while T:
        i = j 
        j = T.pop()
        while j <= i + K and c <= C and T:
                j = T.pop()
                c += 1
        bus += 1
        c = 0 
print(bus)

Submission status: Wrong Answer

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

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


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

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()
passenger = 0
cun = t[0]
ans = 1


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

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()
passenger = 0
cun = t[0]
ans = 1


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

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()
passenger = 0
cun = t[0]
ans = 1


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

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()
passenger = 0
cun = t[0]
ans = 1


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


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

Submission status: Wrong Answer

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

t.sort()
flag = 0 #in bus people
cun = t[0]
ans = 1

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

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c = map(int,input().split())
L = []
for i in range(a):
    L.append(int(input()))
L.sort()
#print(L)
cnt = 0
idx1,idx2 = 0,0
for i in range(a-1):
    if L[i+1] - L[i] > c:
        idx2 = i+1
        cnt += len(L[idx1:idx2])//b+1
        #print(L[idx1:idx2])
        idx1 = idx2
    if i == a-2:
        idx2 = a
        cnt += len(L[idx1:idx2])//b+1
        #print(L[idx1:idx2])
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0
l = 0
while l < n:
    b = 0
    r = l
    while b < c and r < n:
        if t[r] - t[l] <= k:
            b += 1
            r += 1
        if r == n:
            cnt += 1
    l = r + 1
    cnt += 1
print(cnt)

Submission status: Wrong Answer

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

cnt = 0
l = 0
while l < n - 1:
    b = 0
    r = l
    while b < c and r < n:
        if t[r] - t[l] <= k:
            b += 1
            r += 1
        if r == n:
            cnt += 1
    l = r
    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, C, K = map(int, input().split())
res = 1
t = []
for _ in range(N):
  t.append(int(input()))
t.sort()
x = t.pop()
c = 1
for i in range(N - 1):
  y = t.pop()
  if abs(x - y) > K or (c >= C):
    res += 1
    x = y
    c = 1
  c += 1
print(res)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
ans = 1
busNin = 0
busFirstp = 0
for i in range(n):
    if t[i]-t[busFirstp] > k or busNin == c:
        ans += 1
        busNin = 1
        busFirstp = i
        continue
    busNin += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
ans = 1
busNin = 0
busFirstp = 0
for i in range(n):
    if t[i]-t[busFirstp] > k or busNin == c:
        ans += 1
        busNin = 1
        busFirstp = i
    busNin += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t_list = []
for i in range(n):
  t_list.append(int(input()))
t_list.sort()
tt = t_list[0]
ans = 1
cnt = 1
for m in range(1,n):
  if cnt +1 >c or tt +k < t_list[i]:
    ans += 1
    cnt =1
    tt = t_list[i]
  else:
    cnt += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t_list = []
for i in range(n):
  t_list.append(int(input()))
t_list.sort()
tt = t_list[0]
ans = 1
cnt = 1
for m in range(1,n):
  if t_list[i] - tt <= k and cnt < c:
    cnt += 1
  elif t_list[i] - tt >k:
    ans += 1
    tt = t_list[i]
    cnt = 1
  elif cnt >=c:
    ans += 1
    tt = t_list[i]
    cnt = 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t_list = []
for i in range(n):
  t_list.append(int(input()))
t_list.sort()
tt = t_list[0]
ans = 1
cnt = 1
for m in range(1,n):
  if t_list[i] - tt <= k and cnt <= c-1:
    cnt += 1
  elif t_list[i] - tt >k:
    ans += 1
    tt = t_list[i]
    cnt = 1
  elif cnt >c-1:
    ans += 1
    tt = t_list[i]
    cnt = 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
s=[]
for i in range(n):
    s.append(int(input()))
s.sort()
ans=1
count=0
a=s[0]
for i in range(1,n):
    if s[i]-a>k:
        a=s[i]
        count=1
        ans+=1
    else:
        count+=1
    if count==c:
        if i!=n-1:
            count=0
            ans+=1
            a=s[i]
    #print(a,count,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
s=[]
for i in range(n):
    s.append(int(input()))
s.sort()
ans=1
count=0
a=s[0]
for i in range(1,n):
    if s[i]-a>k:
        a=s[i]
        count=1
        ans+=1
    else:
        count+=1
    if count==c:
        count=0
        ans+=1
        a=s[i]
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
s=[]
for i in range(n):
    s.append(int(input()))
s.sort()
ans=1
count=0
a=s[0]
for i in range(1,n):
    if s[i]-a>k:
        a=s[i]
        count+=1
        ans+=1
    else:
        count+=1
    if count==c:
        count=0
        ans+=1
        a=s[i]
print(ans)

Submission status: Wrong Answer

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

Ts = sorted(Ts)
bus_num = 1
bus_i = [1]
bus_t = Ts[0]
for t in Ts:
    if (t<=(bus_t+K)) & (len(bus_i) <= C):
        bus_i.append(1)
    else:
#         print("add bus")
        bus_i = []
        bus_t = t
        bus_num +=1
print(bus_num)

Submission status: Wrong Answer

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

bus_num = 1
bus_i = [1]
bus_t = sorted_Ts[0]
for t in sorted_Ts:
    if (t<=(bus_t+K)) & (len(bus_i) <= C):
        bus_i.append(1)
    else:
#         print("add bus")
        bus_i = []
        bus_t = t
        bus_num +=1
print(bus_num)

Submission status: Wrong Answer

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

bus_num = 1
bus_i = [1]
bus_t = sorted_Ts[0]
for t in sorted_Ts:
    if (t<=(bus_t+K)) & (len(bus_i) <= C):
        bus_i.append(1)
    else:
        #print("add bus")
        bus_i = []
        bus_t = t
        bus_num +=1
print(bus_num)

Submission status: Wrong Answer

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

bus_num = 1
bus_i = [1]
bus_t = sorted_Ts[0]
for t in sorted_Ts:
    if (t<=(bus_t+K)) & (len(bus_i) <= C):
        bus_i.append(1)
    else:
        print("add bus")
        bus_i = []
        bus_t = t
        bus_num +=1
print(bus_num)

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
time = T[0] + K
answer = 0
passenger = 0
for i, t in enumerate(T):
    if time < t or passenger == C:
        answer += 1 # i-1までのバス
        passenger = 0
        time = t + K
    else:
        passenger += 1
    if i == N - 1:
        answer += 1
print(answer)

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.sort()
T = [[t, t+K] for t in T]

bus = [[]]
bus_no = 0
limit = T[0][1]

for t in T:
    if (len(bus[bus_no]) < C and t[0] < limit):
        bus[bus_no].append(t)
    else:
        bus.append([])
        bus_no += 1
        bus[bus_no].append(t)
        limit = t[1]

print(len(bus))

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

bus=0
wait_p=0
first_t=-1

for i in range(n):
    ti=t[i]
    if(first_t==-1):
        first_t=ti

    wait_p+=1

    if(wait_p >= c):
        bus+=1
        first_t=-1
        wait_p=0
    elif(ti > first_t+k):
        bus+=1
        first_t=ti
        wait_p=1


if(first_t!=-1 or wait_p > 0):
    bus+=1

print(bus)

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

bus=0
wait_p=0
first_t=-1

for i in range(n):
    ti=t[i]
    if(first_t==-1):
        first_t=ti

    wait_p+=1

    if(wait_p >= c):
        bus+=1
        first_t=-1
        wait_p=0
    elif(ti > first_t+k):
        bus+=1
        first_t=ti
        wait_p=1


if(first_t!=-1):
    bus+=1

print(bus)

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

bus=0
wait_p=0
first_t=-1

for i in range(n):
    ti=t[i]
    if(first_t==-1):
        first_t=ti

    wait_p+=1

    if(wait_p >= c):
        bus+=1
        first_t=-1
        wait_p=0
    elif(ti > first_t+k):
        bus+=1
        first_t=ti
        wait_p=0


if(first_t!=-1):
    bus+=1

print(bus)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
ans=0
l=[]
for i in range(n):
  l.append(int(input()))
l.sort()
ride=[]
while l:
  a=l.pop(0)
  rode=a
  ride.append(a)
  while len(ride)<c:
    if l==[]:
      ans+=1
      break
    b=l[0]
    if b>ride[0]+k:
      ride.clear()
      ans+=1
      break
    l.pop(0)
    ride.append(b)
    if len(ride)==c:
      ans+=1
      ride.clear()
      break
print(ans)

Submission status: Wrong Answer

Solution code:
# AGC011
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort(reverse=True)
ans = 1
c_cnt = 0
now = T[0]
for i in range(N):
    if c_cnt > C or now > T[i] + K:     # 乗れない時
        ans += 1
        c_cnt = 0
        now = T[i]
    else:
        c_cnt += 1
    if i == N - 1:
        if c_cnt != 0:
            ans += 1
        else:
            pass
print(ans)

Submission status: Wrong Answer

Solution code:
# AGC011
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort(reverse=True)
ans = 1
c_cnt = 0
#print(T)
now = T[0]
for i in range(N):
    if c_cnt > C:
        ans += 1
        c_cnt = 1
        now = T[i]
    else:
        if i == N-1:
            ans += 1
            break
        if c_cnt <= C:
            if now <= T[i] + K:
                c_cnt += 1
            else:
                ans += 1
                c_cnt = 1
                now = T[i]
    #print(i, T[i], ans)
print(ans)

Submission status: Wrong Answer

Solution code:
# AGC011
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort(reverse=True)
ans = 0
flag = False
i = 0
while 1:
    if flag:
        break    
    for k in range(C-1):
        if i+1+k >= N-1:
            ans += 1
            flag = True
            break
        if T[i+1+k] + K < T[i]:
            i += k
            ans += 1
            break
        if k == C - 2:
            i += k
            ans += 1
            break
    i += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    if t >= dead_line_t:
        # 出発しないと怒り出す客がいる
        waiting_n = 0
        bus_count += 1

    if i == len(t_list) - 1:
        # 最後の一人はどのみち乗せるしかない
        bus_count += 1

ans = bus_count
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()

vacant = c
bus = 1
departure = t[0] + k

for i in range(n):
    if vacant == 0:
        bus += 1
        vacant = c
        departure = t[i] + k
        # print("a " + str(t[i]) + "is bus:" + str(bus) )
    elif vacant > 0 and vacant <= c:
        if departure >= t[i]:
            vacant -=1
            # print("b " + str(t[i]) + "is bus:" + str(bus) )
        elif departure < t[i]:
            bus += 1
            vacant = c - 1
            departure = t[i] + k
            # print("c " + str(t[i]) + "is bus:" + str(bus))

print(bus)