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

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

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

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

sortT = sorted(T)
pre_ti = sortT[0]
ans = 1
c = 0
for ti in sortT:
    c += 1
    if ti - pre_ti < K and c <= C:
        continue
    c = 1
    ans += 1
    pre_ti = ti

print(ans)

Submission status: Wrong Answer

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

sortT = sorted(T)
pre_ti = sortT[0]
ans = 1
for ti in sortT:
    if ti - pre_ti < K:
        continue
    ans += 1
    pre_ti = ti

print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]
t.sort()
ans=0
num=0
for i in range(n):
    if num>=n:
        break
    num2=t[num]+k
    ans+=1
    for j in range(c-1):
        if num==n:
            break
        if t[num]>num2:
            num-=1
            break
        num+=1
    num+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N, C, K = map(int,input().split())
T = []
ans = 0 #バス内の人数
num = 1 #バスの台数
for i in range(N):
    ans = int(input())
    T.append(ans)
T = sorted(T)
S =  T[0] + K #バスの発車時刻
for i in range(N):
    if T[i] <= S and ans < C:
        ans += 1
    else:
        num += 1
        S = T[i] + K
        ans = 1
print(num - 1)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
from math import ceil
def main():
    n, c, k = map(int, input().split())
    times = defaultdict(int)
    for _ in range(n):
        times[int(input()) + k] += 1
    # ts:時間順に「時間ごとの出発したい人数」を並べたもの
    ts = dict(sorted(times.items()))

    r = 0
    busg = c # バスに乗せられる人数
    busstart = - k - 1
    for tse in ts:

        if busstart + k < tse: # 前のバスに間に合わない場合。バスを仕立てる
            r += ceil(ts[tse] / c)
            busg = c - ts[tse] % c
            busstart = tse
        else:
            if busg >= ts[tse]: #バスに乗りきれる場合
                busg -= ts[tse]
            else:             # バスに乗り切れない場合。バスを仕立てる。
                ts[tse] -= busg
                busstart = tse
                r += ceil(ts[tse] / c)
                busg = c - ts[tse] % c
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
from math import ceil
def main():
    n, c, k = map(int, input().split())
    times = defaultdict(int)
    for _ in range(n):
        times[int(input()) + k] += 1
    # ts:時間順に「時間ごとの出発したい人数」を並べたもの
    ts = dict(sorted(times.items()))

    r = 0
    busg = c # バスに乗せられる人数
    busstart = - k - 1
    for tse in ts:

        if busstart + k < tse: # 前のバスに間に合わない場合。バスを仕立てる
            r += 1
            busg = c
            busstart = tse
        if busg >= ts[tse]: #バスに乗りきれる場合
            busg -= ts[tse]
        else:             # バスに乗り切れない場合。バスを仕立てる。
            if busstart == tse: # この時間でバスを仕立てていたなら重複カウント防止のため-1
                r -= 1
            ts[tse] -= busg
            busstart = tse
            r += ceil(ts[tse] / c)
            busg = c - ts[tse] % c
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
from math import ceil
def main():
    n, c, k = map(int, input().split())
    times = defaultdict(int)
    for _ in range(n):
        times[int(input()) + k] += 1
    # ts:時間順に「時間ごとの出発したい人数」を並べたもの
    ts = dict(sorted(times.items()))

    r = 0
    busg = c # バスに乗せられる人数
    busstart = - k - 1
    for tse in ts:
        if busstart + k < tse: # 前のバスに間に合わない場合。バスを仕立てる
            r += 1
            busg = c
            busstart = tse
        if busg >= ts[tse]: #バスに乗りきれる場合
            busg -= ts[tse]
        else:             # バスに乗り切れない場合。バスを仕立てる。
            ts[tse] -= busg
            busstart = tse
            r += ceil(ts[tse] / c)
            busg = c - ts[tse] % c
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    n, c, k = map(int, input().split())
    times = defaultdict(int)
    for _ in range(n):
        times[int(input()) + k] += 1
    ts = dict(sorted(times.items()))

    r = 0
    busg = c # バスに乗せられる人数
    busstart = -k - 1
    for tse in ts:
        if tse > busstart + k: # 前のバスがでていたらバスを仕立てる
            r += 1
            busg = c
            busstart = tse
        if ts[tse] >= busg: # バスがうまったらバスを仕立てる
            ts[tse] -= busg
            busstart = tse
            p = ts[tse] // c
            r += p + 1
            busg = c - ts[tse] % c
        else:
            busg -= ts[tse]
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

tmp, cnt, ans = 0, 0, 0
for t in T:
  if not tmp:
    tmp = t + K
    cnt += 1
    ans += 1
  elif tmp <= t or cnt == C:
    tmp = t + K
    cnt = 1
    ans += 1
  else:
    cnt += 1
    
print(ans)

Submission status: Wrong Answer

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

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

tmp, cnt, ans = 0, 0, 0
for t in T:
  if not tmp:
    tmp = t + K
    cnt += 1
    ans += 1
  elif tmp <= t or cnt == C:
    tmp = t + K
    cnt = 0
    ans += 1
  else:
    cnt += 1
    
print(ans)

Submission status: Wrong Answer

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

i=0
ans=0
T.sort()
while(i<n):
    time=T[i]+k
    i+=1
    ans+=1

    x=0
    while(x<c-1 and i+x<n):
        if T[i+x]<=time:
            i+=1
        x+=1

print(ans)

Submission status: Wrong Answer

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

i=0
ans=0
T.sort()
while(i<n):
    time=T[i]+k
    i+=1
    ans+=1

    x=0
    while(x<c and i+x<n):
        if T[i+x]<=time:
            i+=1
        x+=1

print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N, C, K = [int(item) for item in input().split()]
    Ts = [int(input()) for _ in range(N)]
    Ts.sort()

    res = 0
    temp_psg = 0
    lim = Ts[0] + K

    for i in range(N):
        temp_psg += 1
        if Ts[i] > lim:
            res += 1
            temp_psg = 1
            lim = Ts[i] + K
        else:
            if temp_psg == C:
                res += 1
                temp_psg = 1
                lim = Ts[i] + K
        # print(Ts[i], temp_psg, res, lim)
    print(res)


if __name__ == "__main__":
    resolve()

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()
ans = 0
while len(T) > 0:
  start = T[0]
  for i in range(1, min(C, len(T))):
    if T[i] > start+K:
      i -= 1
      break
  ans += 1
  T = T[i+1:]
print(ans)

Submission status: Wrong Answer

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


from collections import deque

T = deque(sorted(T))

ind_ref = 0
t_ref = 0

bus = 0
member = 0

while T != deque([]):
    t = T[0]
    if t - t_ref <= K and member < C:
        member += 1
        t_tmp = T.popleft()
#        print(t_tmp, 'ok')
#        print(member)
    else:
        bus += 1
        member = 0
        t_ref = T[0]
#        print()
#        print(t_ref, 'new')
if member > 0:
    bus += 1
print(bus)

Submission status: Wrong Answer

Solution code:
import sys,bisect,math
input = sys.stdin.readline

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

n = 0
cnt = 0
while n < N:
    target = T[n]+K
    nb = n
    n = bisect.bisect_left(T,target)
    if n - nb > C:
        n = nb + C
    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys,bisect,math
input = sys.stdin.readline

N,C,K = list(map(int,input().split()))
T = sorted([int(input()) for i in range(N)])
T.append(T[-1])
T.append(T[-1])

cnt = 0
n = 0
c = 1
while n < N:
    c = 1
    target = T[n]+K
    while c <= C and n+c < N :
        if T[n+c] < target:
            c +=1
        else:
            break
    n = n+c
    cnt += 1
            
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys,bisect,math
input = sys.stdin.readline

N,C,K = list(map(int,input().split()))
T = sorted([int(input()) for i in range(N)])
T.append(T[-1])
T.append(T[-1])

cnt = 0
n = 0
while n<N:
    target = T[n] + K
    if T[n+1]>= target:
        n += 1
    elif T[n+2] >= target:
        n +=2
    else:
        n += 3
    cnt += 1
print(cnt)

Submission status: Wrong Answer

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

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

cnt = 0
n = 0
while n < len(T):
    target = T[n]+K
    cnt += 1
    n = bisect.bisect_left(T,target)
print(cnt)

Submission status: Wrong Answer

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

first = 0
bus = 1
nowpassenger = 1
for i in range(N):
    watingtime = T[i] - T[first]
    if watingtime > K:
        bus += 1
        first = i
        nowpassenger = 0
    elif nowpassenger > C:
        bus += 1
        first = i
        nowpassenger = 0
    else:
        nowpassenger += 1

print(bus)

Submission status: Wrong Answer

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

first = 0
bus = 1
nowpassenger = 0
for i in range(N):
    watingtime = T[i] - T[first]
    if watingtime > K:
        bus += 1
        first = i
        nowpassenger = 0
    elif nowpassenger >= C:
        bus += 1
        first = i
        nowpassenger = 0
    else:
        nowpassenger += 1

print(bus)

Submission status: Wrong Answer

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

first = 0
bus = 0
nowpassenger = 0
for i in range(N):
    watingtime = T[i] - T[first]
    if watingtime > K:
        bus += 1
        first = i
        nowpassenger = 0
    elif nowpassenger >= C:
        bus += 1
        first = i
        nowpassenger = 0
    else:
        nowpassenger += 1

print(bus + 1)

Submission status: Wrong Answer

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

first = 0
bus = 0
nowpassenger = 0
for i in range(N):
    watingtime = T[i] - T[first]
    if watingtime > K:
        bus += 1
        first = i
    elif nowpassenger >= C:
        bus += 1
        first = i
        nowpassenger = 0
    nowpassenger += 1

print(bus + 1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, c, k = map(int, input().split())
a = sorted([int(input()) for i in range(n)])

ans = 0
busp = 0
machi = 0

for i in a:
    if busp == 0:
        ans += 1
        busp += 1
        machi = i + k

    elif i <= machi:
        busp += 1
        if busp >= c:
            busp = 0
            machi = 0

    elif i > machi:
        ans += 1
        busp = 1
        machi = i + k

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, c, k = map(int, input().split())
a = sorted([int(input()) for i in range(n)])

ans = 0
busp = 0
machi = 0

for i in a:
    if busp == 0:
        busp += 1
        machi = i + k

    elif i <= machi:
        busp += 1
        if busp >= c:
            ans += 1
            busp = 0
            machi = 0

    elif i > machi:
        ans += 1
        busp = 1
        machi = i + k

if busp >= 1:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, c, k = map(int, input().split())
a = sorted([int(input()) for i in range(n)])

ans = 0
busp = 0
machi = 0

for i in a:
    if busp == 0:
        busp += 1
        machi = i + k

    elif i <= machi:
        busp += 1
        if busp >= c:
            ans += 1
            busp = 0

    elif i > machi:
        ans += 1
        busp = 1
        machi = i + k

if busp >= 1:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n, c, k=map(int,input().split())
bus=1
pssgr=0
fst_pssgr=0
t_lst=[]
for i in range(n):
    t=int(input())
    t_lst.append(t)

t_lst.sort()

for i in range(n):
    if t_lst[i]-t_lst[fst_pssgr]>k:
        bus+=1
        pssgr=1
        fst_pssgr=i
    pssgr+=1
    if pssgr==c and i<n-1:
        bus+=1
        pssgr=0
        fst_pssgr=i+1

print(bus)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
MOD = pow(10, 9) + 7

N, C, K, *T = map(int, read().split())
T.sort()

acc = 0
n_bus = 0
cnt = 0
for t in T:
    if cnt == 0:
        acc = t + .5
        n_bus += 1
        cnt = 1
        continue

    if t - acc <= K:
        cnt += 1
    else:
        cnt = 1
        acc = t + .5
        n_bus += 1
        continue
    if cnt == C:
        cnt = 0

print(n_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()
res = 0
cnt = 0
i = 0

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

Submission status: Wrong Answer

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

    T = [int(input()) for _ in range(N)]
    T.sort()
    person_counts = 0
    bus_counts = 0
    for t in T:

        if person_counts == 0:
            first = t + K
            person_counts += 1

        if t > first:
            bus_counts += 1
            person_counts = 1
            continue

        if t == C - 1:
            bus_counts += 1
            person_counts = 0
            continue

        person_counts += 1

    if person_counts > 0:
        print(bus_counts + 1)
    else:
        print(bus_counts)

Submission status: Wrong Answer

Solution code:
import heapq
from typing import Generic, Optional, List, Tuple, Dict, TypeVar

T = TypeVar("T")


class PriorityQueue(Generic[T]):
    def __init__(self):
        self.DONE = -10000
        self.heap: List[Tuple[int, T]] = []
        self.priorities: Dict[T, int] = {}  # Map from state to priority

    # Insert |state| into the heap with priority |newPriority| if
    # |state| isn't in the heap or |newPriority| is smaller than the existing
    # priority.
    # Return whether the priority queue was updated.
    def update(self, state: T, newPriority: int) -> bool:
        oldPriority = self.priorities.get(state)
        if oldPriority is None or newPriority < oldPriority:
            self.priorities[state] = newPriority
            heapq.heappush(self.heap, (newPriority, state))
            return True
        return False

    # Returns (state with minimum priority, priority)
    # or (None, None) if the priority queue is empty.
    def removeMin(self) -> Tuple[Optional[T], Optional[int]]:
        while len(self.heap) > 0:
            (priority, state) = heapq.heappop(self.heap)
            if self.priorities[state] == self.DONE:
                continue  # Outdated priority, skip
            self.priorities[state] = self.DONE
            return (state, priority)
        return (None, None)  # Nothing left...

    def is_empty(self):
        return len(self.heap) == 0


if __name__ == "__main__":
    N, C, K = [int(x) for x in input().split(" ")]

    T = [int(input()) for _ in range(N)]
    pq = PriorityQueue()
    bus_counts = 0

    for t in T:
        pq.update(t, t + K)
    t, t_dep = pq.removeMin()
    person_counts = 1
    while not pq.is_empty():
        # print(person_counts)
        if person_counts <= C:
            # print(t, t_dep)
            t, p = pq.removeMin()
            # print(t, p)
            if t > t_dep:
                pq.update(t, p)
                bus_counts += 1
                # print(bus_counts)
                person_counts = 0
                t_dep = p
            elif t == t_dep:
                bus_counts += 1
                person_counts = 0

            else:
                person_counts += 1

    print(bus_counts + 1)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N, C, K =I()
T = []
for i in range(N):
    t = k()
    T.append(t)

T.sort()
a = T[0]+K
pas = 0
ans = 1

for i in range(N):
    if pas == C or a <= T[i]:
        pas = 0
        ans += 1
        a = T[i]+K
    else:
        pas += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N, C, K =I()
T = []
for i in range(N):
    t = k()
    T.append(t)

T.sort()
a = T[0]+K
pas = 0
ans = 1

for i in range(N):
    if pas == C or a < T[i]:
        pas = 0
        ans += 1
        a = T[i]+K
    else:
        pas += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k=[int(x) for x in input().rstrip().split()]
t=[]
for i in range(n):
  T = int(input())
  t.append([T,T+k])

t=sorted(t,key=lambda x :x[0])

ans=0
right=t[0][1]
cnt=0
for i in range(n):
  s,e=t[i][0],t[i][1]

  if s<=right<=e:
    cnt+=1

    if cnt==c:
      ans+=1
      cnt=0
      if i+1<n-1:
        right=t[i+1][1]

  else:
    ans+=1
    cnt=0
    if i+1<n-1:
      right=t[i+1][1]

ans+=cnt
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k=[int(x) for x in input().rstrip().split()]
t=[]
for i in range(n):
  T = int(input())
  t.append([T,T+k])

t=sorted(t,key=lambda x :x[0])


right=0
ans=0
cnt=0
for s,e in t:
  if s<= right<=e:
    cnt+=1
    if cnt==c:
      ans+=1
      right=e
  else:
    ans+=1
    right=e
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k=[int(x) for x in input().rstrip().split()]
t=[]
for i in range(n):
  T = int(input())
  t.append([T,T+c])

t=sorted(t,key=lambda x :x[0])

# print(t)
right=0
ans=0
cnt=0
i=0
for s,e in t:
  if s<= right<=e:
    cnt+=1
    if cnt==c:
      ans+=1
      right=e
      cnt=0
  else:
    ans+=1
    right=e
  i+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k=[int(x) for x in input().rstrip().split()]
t=[]
for i in range(n):
  T = int(input())
  t.append([T,T+c])

t=sorted(t,key=lambda x :x[0])


right=0
ans=0
cnt=0
for s,e in t:
  if s<= right<=e:
    cnt+=1
    if cnt==c:
      ans+=1
      right=e
  else:
    ans+=1
    right=e
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k=[int(x) for x in input().rstrip().split()]
t=[]
for i in range(n):
  T = int(input())
  t.append([T,T+c])

t=sorted(t,key=lambda x :x[0])


right=0
ans=0
for s,e in t:
  if s<= right<=e:
    continue
  else:
    ans+=1
    right=e
print(ans)

Submission status: Wrong Answer

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

n, c, k = [int(w) for w in input().split()]
la = [int(input()) for _ in range(n)]
la.sort()
lak = [a + k for a in la]

ind = 0
ans = 0
while ind < n:
    ride = bisect.bisect_right(la, lak[ind]) - ind

    ind += min(ride, k)
    ans += 1

print(ans)

Submission status: Wrong Answer

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

n, c, k = [int(w) for w in input().split()]
la = [int(input()) for _ in range(n)]
la.sort()
lak = [a + k for a in la]

ind = 0
ans = 0
while ind < n:
    ride = bisect.bisect_left(la, lak[ind]) - ind
    
    ind += min(ride,k)
    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
count = 0
time = 0
start = -1
for i in range(N):
  if start == -1:
    start = i
  if i != N-1:
    if T[i] > T[start] + K or i+1 -start == C:
      ans += 1
      start = -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 = 0
count = 0
time = 0
for i in range(N):
  if T[i] > time + K:
    ans += 1
    count = 0
  if count == 0:
    time = T[i]
  count += 1
  if count == C:
    ans += 1
    count = 0
if count > 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)])
print(T)
ans = 0
count = 0
time = 0
for i in range(N):
  if T[i] > time + K:
    ans += 1
    count = 0
  if count == 0:
    time = T[i]
  count += 1
  if count == C:
    ans += 1
    count = 0
if count > 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)])
ta = 0; cnt = 0; ans = 0
for i in range(n - 1):
    if ta + T[i + 1] - T[i] < k and cnt < c:
        ta = ta + T[i + 1] - T[i]
        cnt += 1
        if cnt >= c:
            ans += 1
            ta = 0; cnt = 0
    else:
        ans += 1
        ta = 0; cnt = 0
print(ans + 1)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])
ta = 0; cnt = 0; ans = 0
for i in range(n - 1):
    print(i, ta, cnt, ans)
    if ta + T[i + 1] - T[i] < k and cnt < c:
        ta = ta + T[i + 1] - T[i]
        cnt += 1
        if cnt >= c:
            ans += 1
            ta = 0; cnt = 0
    else:
        ans += 1
        ta = 0; cnt = 0
    print(i, ta, cnt, ans)
print(ans + 1)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])
ta = 0; cnt = 0; ans = 0
for i in range(n - 1):
    if ta + T[i + 1] - T[i] < k and cnt < c:
        ta = ta + T[i + 1] - T[i]
        cnt += 1
        if cnt >= 3:
            ans += 1
            ta = 0; cnt = 0
    else:
        ans += 1
        ta = 0; cnt = 0
print(ans + 1)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])
ta = 0; cnt = 1; ans = 0
for i in range(1, n):
    if ta + T[i] - T[i - 1] < k and cnt < c:
        ta = ta + T[i] - T[i - 1]
        cnt += 1
    else:
        ans += 1
        ta = 0; cnt = 0
print(ans + 1)

Submission status: Wrong Answer

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

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')
from math import *


def main():
	n,c,k=MI()
	T=[II() for _ in range(n)]
	T.sort()
	#print(T)
	
	ans=0
	cnt=0
	now=0
	
	for i in range(n):
		if cnt==0:
			ans+=1
			now=T[i]
			cnt=1
		else:
			if now+k<=T[i]:
				cnt+=1
				if cnt==c:
					cnt=0
			else:
				cnt=0
	
	print(ans)


if __name__=="__main__":
	main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')
from math import *


def main():
	n,c,k=MI()
	T=[II() for _ in range(n)]
	T.sort()
	#print(T)
	
	ans=0
	cnt=0
	now=0
	
	for i in range(n):
		if cnt==0:
			ans+=1
			now=T[i]
			cnt=1
		else:
			if now+k<=T[i]:
				cnt+=1
				if cnt==k:
					cnt=0
			else:
				cnt=0
	
	print(ans)
	
	
	
	
	
	
	
	
	


	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])
 
in_bus = 0
first = 0
last = 0
bus_count = 0
for i in range(N):
    if (i == 0):
        first = T[i]
        last = T[i] + K
        in_bus += 1
        bus_count += 1
        continue

Submission status: Wrong Answer

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

in_bus = 0
first = 0
last = 0
bus_count = 0
for i in range(N + 1):
    if (i == 0):
        first = T[i]
        last = T[i] + K
        in_bus += 1
        bus_count += 1
        continue

    if (i == N):
        break

    if (in_bus == C):
        bus_count += 1
        in_bus = 0
        first = T[i]
        last = T[i] + K
        continue

    if (T[i] >= first and last >= T[i]):
        in_bus += 1
    else:
        first = T[i]
        last = T[i] + K
        in_bus = 1
        bus_count += 1


print(bus_count + 1)

Submission status: Wrong Answer

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

in_bus = 0
first = 0
last = 0
bus_count = 0
for i in range(N + 1):
    if (i == 0):
        first = T[i]
        last = T[i] + K
        in_bus += 1
        bus_count += 1
        continue

    if (i == N):
        break

    if (in_bus == C):
        bus_count += 1
        in_bus = 0
        first = T[i]
        last = T[i] + K
        continue

    if (T[i] >= first and last >= T[i]):
        in_bus += 1
    else:
        first = T[i]
        last = T[i] + K
        in_bus = 1
        bus_count += 1


print(bus_count - 1)

Submission status: Wrong Answer

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

in_bus = 0
first = 0
last = 0
bus_count = 0
for i in range(N + 1):
    if (i == 0):
        first = T[i]
        last = T[i] + K
        in_bus += 1
        bus_count += 1
        continue

    if (i == N):
        break

    if (in_bus == C):
        bus_count += 1
        in_bus = 0
        first = T[i]
        last = T[i] + K
        continue

    if (T[i] >= first and last >= T[i]):
        in_bus += 1
    else:
        first = T[i]
        last = T[i] + K
        in_bus = 1
        bus_count += 1


print(bus_count)

Submission status: Wrong Answer

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

in_bus = 0
now = 0
bus_count = 1
for i in range(N + 1):
    if (i == 0):
        now = T[i] + K
        in_bus += 1
        continue

    if (i == N):
        break

    if (now == 0 and i != 0):
        now = T[i] + K
        in_bus += 1
        continue

    if (T[i] <= now and T[i - 1] <= T[i]):
        in_bus += 1
    else:
        now = 0
        in_bus = 0
        bus_count += 1

    if (in_bus == C):
        bus_count += 1
        in_bus = 0
        now = 0
        continue


print(bus_count)

Submission status: Wrong Answer

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

in_bus = 0
now = 0
bus_count = 0
for i in range(N):
    if (i == 0):
        now = T[i] + K
        in_bus += 1
        continue

    if (T[i] <= now and T[i - 1] <= T[i]):
        in_bus += 1
    else:
        now = 0
        in_bus = 0
        bus_count += 1

    if (in_bus == C):
        bus_count += 1
        in_bus = 0
        now = 0
        continue

    if (now == 0):
        now = T[i] + K
        in_bus += 1
        continue


print(bus_count)

Submission status: Wrong Answer

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

bus = 0
pa = 1
point = T[0]

for i in T[1:]:
    pa += 1
    if point +K < i or pa > C:
        bus += 1
        pa = 1
        c = i
print(bus+1)

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
point = T[0]

for i in T[1:]:
    pa += 1
    if point +K < i or pa > C:
        bus += 1
        pa = 1
        c = i
print(bus)