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(list(int(input()) for _ in range(N)))

bus = 1
pa = 1

for i in range(N-1):
    if pa < C:
        if T[i]+K >= T[i+1]:
            pa += 1
        else:
            bus += 1
            pa = 1
    else:
        bus += 1
        pa = 1
        continue

print(bus)

Submission status: Wrong Answer

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

bus = 1
pa = 1

for i in range(N-1):
    if pa < C:
        if T[i]+K > T[i+1]:
            pa += 1
        else:
            bus += 1
            pa = 1
    else:
        bus += 1
        pa = 1
        continue

print(bus)

Submission status: Wrong Answer

Solution code:
N,C,K = map(int, input().split())
L = []
for a in range(N):
  L.append(int(input()))
L.sort()
L.append(10**9)
x = 0
y = 0
z = L[0]
for i in range (N+1):
  if y < C and z+K >= L[i]:
    y += 1
  else:
    x += 1
    y = 1
    z = L[i]    
print(x)

Submission status: Wrong Answer

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

lmt = 0
flg = True
tmp_c = c
bus_cnt = 0
for i in range(len(T)-1):
    if flg:
        lmt = T[i] + k
        flg = False
        bus_cnt += 1
    if tmp_c >= 0 or lmt >= T[i]:
        tmp_c -= 1
    if tmp_c <= 0 or lmt <= T[i+1]:
        flg = True
        tmp_c = c
else:
    if tmp_c <= 0 or lmt < T[-1]:
        bus_cnt += 1

print(bus_cnt)

Submission status: Wrong Answer

Solution code:
import bisect

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

T = [0]*(N+1)
for i in range(N):
    T[i+1] = int(input())
T.sort()


#print(T)

ans = 0
left = 1
while True:
    if left > N:
        break
    #print("T[left]",T[left])
    ind = bisect.bisect_left(T, T[left]+K)
    #print("ind",ind)
    left = min(ind, left+C)
    ans += 1
    #print("left",left)
    
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect

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

T = [0]*N
for i in range(N):
    T[i] = int(input())
T.sort()


#print(T)

ans = 0
left = 0
while True:
    if left >= N:
        break
    #print("T[left]",T[left])
    ind = bisect.bisect_right(T, T[left]+K-1)
    #print("ind",ind)
    left = min(ind, left+C)
    ans += 1
    #print("left",left)
    
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect

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

T = [0]*N
for i in range(N):
    T[i] = int(input())
T.sort()

ans = 0
left = 0
while True:
    if left >= N:
        break
    #print("T[left]",T[left])
    ind = bisect.bisect_left(T, T[left]+K)
    #print("ind",ind)
    left = min(ind,left+C)
    ans += 1
    #print("left",left)
    
print(ans)

Submission status: Wrong Answer

Solution code:
N, C, K=map(int, input().split())
X=[]
for _ in range(N):
  X.append(int(input()))
X.sort()
X.append(10**19)
ans=0
tamatta=0
hayaihito=X[0]
for i in range(N):
  if tamatta<C and hayaihito+K>=X[i+1]:
    tamatta+=1
  else:
    tamatta=0
    hayaihito=X[i+1]
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N, C, K=map(int, input().split())
X=[]
for _ in range(N):
  X.append(int(input()))
X.sort()
X.append(10**19)
ans=0
tamatta=0

for i in range(N):
  tamatta+=1
  if tamatta==C or X[i]+K<X[i+1]:
    tamatta=0
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N, C, K=map(int, input().split())
X=[]
for _ in range(N):
  X.append(int(input()))
X.sort()
X.append(10**19)
ans=0
tamatta=0

for i in range(N):
  tamatta+=1
  if tamatta<C and X[i]+K>=X[i+1]:
    continue 
  tamatta=0
  ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,m = map(int,input().split(" "))
ar = [int(input()) for i in range(n)]
ar.sort()
count = 0
b = 0
s = 0
for i,r in enumerate(ar):
    if count == 0:
        s = r 
        count += 1
        if count == c or i == n - 1:
            b += 1
            count = 0
    else:
        if r < s + m:
            count += 1
            if count == c or i == n - 1:
                b += 1
                count = 0
        else:
            b += 1
            count = 0
            s = r
if s == ar[-1]:
    b += 1
print(b)

Submission status: Wrong Answer

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

def main():
    N,C,K = map(int, input().split())
    ret = 0
    busT = -1
    busC = 0
    for i in range(N):
        Ti = int(input())
        if busT==-1:
            busT=Ti+K
            ret+=1
        if Ti<busT and busC<C:
            busC+=1
        elif Ti>busT:
            busT=Ti+K
            busC=1
            ret+=1
        else:
            busT=-1
            busC=0
    print(ret+1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

lt = list()
for i in range(n):
    lt.append(int(input()))
lt.sort()

b = 1  #the number of buses
p = 0  #passengers
m = lt[0]

for i in range(n):
    if p < c and lt[i]-m < k:
        p += 1
    else:
        p = 1
        b += 1
        m = lt[i]
        
print(b)

Submission status: Wrong Answer

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

lt = list()
for i in range(n):
    lt.append(int(input()))
lt.sort()

b = 1  #the number of buses
p = 0  #passengers
m = lt[0]

for i in range(n):
    if p < c-1 and lt[i]-m < k:
        p += 1
    else:
        p = 0
        b += 1
        m = lt[i]

print(b)

Submission status: Wrong Answer

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

lt = list()
for i in range(n):
    lt.append(int(input()))
lt.sort()

b = 1  #the number of buses
p = 0  #passengers
m = lt[0]  #minutes of the last departure

for i in range(n):
    if p < c and lt[i]-m < k:
        p += 1
    else:
        p = 0
        b += 1
        m = lt[i]

print(b)

Submission status: Wrong Answer

Solution code:
n_people,bus_capacity,can_wait = map(int,input().split())
n_waiting = 0
bus_count = 0
arriving_time_ls = [0] * n_people
for i in range(n_people):
    arriving_time_ls[i] = int(input())
arriving_time_ls.sort()

waiting_last = 0
for i in range(1,n_people):
    if arriving_time_ls[i] - arriving_time_ls[waiting_last] >= can_wait:
        bus_count += 1
        waiting_last = i
    elif i - waiting_last + 1 > bus_capacity:
        bus_count += 1
        waiting_last = i
bus_count += 1
print(bus_count)

Submission status: Wrong Answer

Solution code:
n_people,bus_capacity,can_wait = map(int,input().split())
n_waiting = 0
bus_count = 0
arriving_time_ls = [0] * n_people
for i in range(n_people):
    arriving_time_ls[i] = int(input())
arriving_time_ls.sort()

waiting_last = 0
for i in range(1,n_people):
    if arriving_time_ls[i] - arriving_time_ls[waiting_last] >= can_wait:
        bus_count += 1
        waiting_last = i
    elif i - waiting_last + 1 > bus_capacity:
        bus_count += 1
        waiting_last = i
if waiting_last <= n_people - 1:
    bus_count += 1
print(bus_count)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, C, K = MAP()
T = [INT() for _ in range(N)]

T.sort()

ans = 1
cnt = 1
t_limit = T[0] + K

for i in range(1, N):
	if cnt == C:   #人数上限
		t_limit = T[i] + K
		cnt = 1
		ans += 1
	elif T[i] < t_limit: #乗れる
		cnt += 1 
	else:          #待ち時間上限
		t_limit = T[i] + K
		cnt = 1
		ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, C, K = MAP()
T = [INT() for _ in range(N)]

T.sort()
idx = 0
ans = 0

while idx < N :
	tmp = T[idx]
	if idx+C <= bisect_left(T, tmp+K):
		idx += C
	else:
		idx = bisect_left(T, tmp+K)
	ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, C, K = MAP()
T = [INT() for _ in range(N)]

T.sort()
idx = 0
ans = 0

while idx < N :
	tmp = T[idx]
	if idx+C <= bisect_left(T, tmp+K)-1:
		idx += C
	else:
		idx = bisect_left(T, tmp+K)
	ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, C, K = MAP()
T = [INT() for _ in range(N)]

T.sort()
idx = 0
ans = 0

while idx < N :
	tmp = T[idx]
	if idx+C <= bisect(T, tmp+K)-1:
		idx += C
	else:
		idx = bisect_left(T, tmp+K)
	ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, C, K = MAP()
T = [INT() for _ in range(N)]

T.sort()
idx = -1
ans = 0

while idx < N :
	tmp = T[idx]
	if idx+C <= bisect(T, tmp+K)-1:
		idx += C+1
	else:
		idx = bisect_left(T, tmp+K)
	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 = 1
last_t = T[0]
passengers = 0
for t in T:
    if last_t +k >= t and passengers < c:
        passengers += 1
    else:
        last_t = t
        passengers = 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)])

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

t=[]

for _ in range(n):
    t_i = int(input())

    t.append(t_i)

t = sorted(t)

bus=0


index=0
cnt=0
flg=0

start =t[index]
while index<n:

    end = t[index]

    if end<=start+k:
        cnt+=1
        index+=1
        if index==n:
            break
        if cnt==c:
            bus+=1
            start=t[index]
            cnt=1
            index+=1
    else:
        bus+=1
        start=t[index]
        cnt=1
        index+=1

if cnt<=c:
    bus+=1

print(bus)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,c,k=map(int, input().split())
    l=[int(input()) for i in range(n)]
    l.sort()
    saisyo=l[0]
    ninzu=1
    ans=0
    for j in range(1,n):
        x=l[j]-saisyo
        if x<=c and ninzu<k:
            ninzu+=1
        else:
            ans+=1
            saisyo=l[j]
            ninzu=1
    print(ans+1)
resolve()

Submission status: Wrong Answer

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

T.sort()

ans = 0

oko = 0
bus = False
cnt = 0
for i in range(N):
  t = T[i]
  
  if not bus:
    ans += 1
    bus = True
    oko = t + K
    cnt += 1
    continue
    
  if t <= oko:
    if cnt < C:
      cnt += 1
    else:
      bus = True
      oko = t + K
      cnt = 1
      ans += 1
  else:
    cnt = 1
    bus = True
    ans += 1
    
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
a=sorted([int(input()) for _ in range(n)],reverse=True)
cnt=0
cnt2=0
while len(a) > 0:
    b=a.pop()
    cnt+=1
    cnt2+=1
    if cnt2>10000:
        break
    if len(a)==0:
        break
    for i in range(c-1):
        if a[-1]<=b+k:
            a.pop()
            if len(a)==0:
                break
        
print(cnt)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
a=sorted([int(input()) for _ in range(n)],reverse=True)
cnt=0
while len(a) > 0:
    b=a.pop()
    cnt+=1
    if len(a)==0:
        break
    for i in range(c-1):
        if a[-1]<b+k:
            a.pop()
            if len(a)==0:
                break
        
print(cnt)

Submission status: Wrong Answer

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

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

cnt = 0
m = -1
ans = 0
for a, b in T:
    if cnt%c == 0:
        ans += cnt//c
        m = b
        cnt = 1
    if a > m:
        if cnt%c == 0:
            ans += cnt//c
        else:
            ans += cnt//c+1
        m = b
        cnt = 1
    else:
        cnt += 1
else:
    if cnt%c == 0:
        ans += cnt//c
    else:
        ans += cnt//c+1
print(ans)

Submission status: Wrong Answer

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

bus = 1
lastPassenger = T[0]
waiting = 1
for t in T:
    if waiting < C and lastPassenger + K > t:
        waiting += 1
    else:
        waiting = 1
        lastPassenger = t
        bus += 1

print(bus)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
t_lst = [int(input()) for _ in range(n)]
t_lst.sort()
ans = 0
cnt = 0
last = 0
if cnt == 1:
    print(n)
    exit()
for t in t_lst:
    if t > last:
        ans += 1
        last = t + k
        cnt = 1
    else:
        cnt += 1
        if cnt == c:
            last = 0
            cnt = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
t_lst = [int(input()) for _ in range(n)]
t_lst.sort()
ans = 0
cnt = 0
last = 0
for t in t_lst:
    if t > last:
        ans += 1
        last = t + k
        cnt = 1
    else:
        cnt += 1
        if cnt == c:
            last = 0
            cnt = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
t_lst = [int(input()) for _ in range(n)]
t_lst.sort()
ans = 0
cnt = 0
last = 0
for t in t_lst:
    if t > last:
        ans += 1
        last = t + k
        cnt = 1
    else:
        cnt += 1
        if cnt == c:
            last = 0
print(ans)

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()
    count = 0
    ans = 1
    t0 = T[0]
    for t in T:
        if t - t0 <= k:
            count += 1
        if count > c or t - t0 > k:
            ans += 1
            count = 0
            t0 = t
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,c,k = iim()
time = []
for _ in range(n):
    time.append(ii())

time.sort()

bus = 0
fst = -1
ans = 0
for item in time:
    if fst == -1:
        fst = item
    if bus <= c-1 and item-fst <= k:
        bus += 1
    elif bus > c-1:
        bus = 0
        ans += 1
        fst = item
    elif item-fst > k:
        bus = 1
        ans += 1
        fst = item
    

print(ans if bus == 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
temp=t[0]
tempc=1
for i in range(1,n):
  if temp+k<=t[i] or tempc>=c:
    ans=ans+1
    temp=t[i]
    tempc=1
  else:
    tempc=tempc+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.sort()
ans=1
temp=t[0]
tempc=1
for i in range(1,n):
  if temp+k<=t[i] or tempc>c:
    ans=ans+1
    temp=t[i]
    tempc=1
  else:
    tempc=tempc+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.sort()
ans=1
temp=t[0]
tempc=1
for i in range(1,n):
  if temp+k>=t[i] or tempc>c:
    ans=ans+1
    temp=t[i]
    tempc=1
  else:
    tempc=tempc+1
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t = [int(input()) for nesya in range(n)]
t.sort()
bus = 0
wait = []
for i in range(n):
  wait.append(t[i])
  if len(wait) == c:
    bus += 1
    wait = []
  elif wait[0] + k < t[i]:
    bus += 1
    wait = [t[i]]
  elif wait[0] + k == t[i]:
    bus += 1
    wait = []
  if i == n-1 and len(wait) > 0:
    bus += 1
print(bus)

Submission status: Wrong Answer

Solution code:
def main():
    n, c, k = map(int, input().split())
    customers = [int(input()) for i in range(n)]
    
    customers.sort()
    bus_count = 0
    in_bus = []

    for i in range(n):
        if len(in_bus) == 0:
            in_bus.append(customers[i])
        elif len(in_bus) < c and customers[i] < in_bus[0] + k:
            in_bus.append(customers[i])
        else:
            bus_count += 1
            in_bus = []
            in_bus.append(customers[i])
    
    print(bus_count+1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

times = [int(input()) for x in range(N)]
times.sort()

count = 0
prev = None
passenger = 0

for t in times:
    passenger += 1
    if passenger == C:
        count += 1
        passenger = 0
    elif prev is not None:
        if t - prev > K:
            count += 1
            passenger = 1
    prev = t

if passenger:
    count += 1

print(count)

Submission status: Wrong Answer

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

times = [int(input()) for x in range(N)]
times.sort()

count = 0
passenger = 0

prev = times[0]
passenger = 1

for t in times[1:]:
    passenger += 1
    if t - prev > K:
        count += 1
        passenger = 1
    elif passenger == C:
        count += 1
        passenger = 0
    prev = t


if passenger:
    count += 1

print(count)

Submission status: Wrong Answer

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

times = [int(input()) for x in range(N)]
times.sort()

count = 0
passenger = 0

prev = times[0]
passenger = 1

for t in times[1:]:
    passenger += 1
    if t - prev > K:
        count += 1
        passenger = 1
    if passenger == C:
        count += 1
        passenger = 0
    prev = t


if passenger:
    count += 1

print(count)

Submission status: Wrong Answer

Solution code:
#AGC011-A Airport Bus
"""
時刻順にソート
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,c,k = map(int,readline().split())
t = []
for i in range(n):
    t.append(int(readline()))

t.sort()
res_k = t[0]
res_c = 0
ans = 0
for i in range(n):
    res_c += 1
    if i+1 < n:
        if t[i+1] - res_k >= k:
            ans += 1
            res_c = 0
            res_k = t[i+1]
    if res_c == c:
        ans += 1
        if i+1 < n:
            res_k = t[i+1]
        res_c = 0

print(ans if res_c == 0 else ans + 1)

Submission status: Wrong Answer

Solution code:
#AGC011-A Airport Bus
"""
時刻順にソート
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,c,k = map(int,readline().split())
t = []
for i in range(n):
    t.append(int(readline()))

t.sort()
res_k = t[0]
res_c = 0
ans = 0
for i in range(n):
    res_c += 1
    if i+1 < n:
        if t[i+1] - res_k >= k:
            ans += 1
            res_c = 0
            res_k = t[i+1]
    elif res_c == c:
        ans += 1
        if i+1 < n:
            res_k = t[i+1]
        res_c = 0

print(ans if res_c == 0 else ans + 1)

Submission status: Wrong Answer

Solution code:
#AGC011-A Airport Bus
"""
時刻順にソート
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,c,k = map(int,readline().split())
t = []
for i in range(n):
    t.append(int(readline()))

t.sort()

res = t[0] #k
res2 = 0 #c
ans = 0
for i in range(n):
    if t[i] - res >= k:
        ans += 1
        if i + 1 < n:
            res = t[i+1]
        res2 = 1
        continue
    res2 += 1
    if res2 == c:
        ans += 1
        if i + 1 < n:
            res = t[i+1]
        res2 = 0
    


print(ans if res2==0 else ans +1)

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

ans+=1
print(ans)

Submission status: Wrong Answer

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

if bus != c:
    ans += 1
print(ans)

Submission status: Wrong Answer

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

if bus != c:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = [int(x) for x in input().split()]
t = [int(input()) for _ in range(n)]
t.sort()
bus = c
last_bus = 0
ans = 0
for i in range(n):
    if t[i] >= last_bus or bus < 0:
        ans += 1
        last_bus = t[i]+k
        bus = c-1
    else:
        bus -= 1

print(ans)

Submission status: Wrong Answer

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

if bus != 0:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = [int(x) for x in input().split()]
t = [int(input()) for _ in range(n)]
bus = 0
last_bus = 0
ans = 0
for x in t:
    if x - last_bus >= k or bus == c:
        ans += 1
        last_bus = x
        bus = 1
    else:
        bus += 1

if bus != 0:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

T_list = list() #左がもっとも早く着いた人

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

T_list.sort(reverse=False)

waiting_deque = deque(T_list)
ans = 0

while 1:
    if len(waiting_deque) != 0:
        ans += 1
        bus_passenger = list()
        bus_passenger.append(waiting_deque.popleft())
        while 1:
            if len(waiting_deque)!=0 and len(bus_passenger) < C and bus_passenger[0] + K > waiting_deque[0]:
                bus_passenger.append(waiting_deque.popleft())
            else:
                #print(bus_passenger)
                break
    else:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

T_list = list() #左がもっとも早く着いた人

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

T_list.sort(reverse=False)

waiting_deque = deque(T_list)
ans = 0

while 1:
    if len(waiting_deque) != 0:
        ans += 1
        bus_passenger = list()
        bus_passenger.append(waiting_deque.popleft())
        while 1:
            if len(waiting_deque)!=0 and len(bus_passenger) < C and bus_passenger[0] + K > waiting_deque[0]:
                bus_passenger.append(waiting_deque.popleft())
            else:
                print(bus_passenger)
                break
    else:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n,c,k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    t.sort()
    res = 1
    time, hito = 0, 0
    for i in range(n):
        if t[i] - time > k:
            time = t[i]
            res += 1
            hito = 1
        elif hito + 1 > c:
            time = t[i]
            res += 1
            hito = 1
        else:
            hito += 1

    print(res)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n,c,k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    t.sort()
    res = 1
    time, hito = 0, 0
    for i in range(n):
        if t[i] - time > k:
            time = t[i]
            res += 1
            hito = 0
        if hito + 1 > c:
            time = t[i]
            res += 1
            hito = 0
        hito += 1

    print(res)

if __name__ == '__main__':
    main()