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 sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


# ワーシャルフロイド (任意の2頂点の対に対して最短経路を求める)
# 計算量n^3 (nは頂点の数)
def warshall_floyd(d, n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定



# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
n, c, k = map(int, input().split())
t = sorted([int(input()) for i in range(n)])
ans = 0
cnt = 0
for i in range(n):
    if cnt == 0:
        cnt = 1
        ans += 1
        continue
    if t[i] - t[i - 1] > k or cnt == c:
        cnt = 1
        ans += 1
        continue
    cnt += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# AGC011 A Airport Bus
import bisect
from collections import deque

n, c, k = map(int, input().split())
t_list = [int(input()) for _ in range(n)]

t_list.sort()
t_list = deque(t_list)
ans = 0

while len(t_list) > 0:
    _tmp = t_list.popleft() + k
    _idx = bisect.bisect_right(t_list, _tmp)
    if c-1 <= _idx:
        for _ in range(c-1):
            t_list.popleft()
    else:
        for _ in range(_idx-1):
            t_list.popleft()
    ans += 1

print(ans)

Submission status: Wrong Answer

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

t = [0] * n
for i in range(n):
    t[i] = int(input())
t = sorted(t)
ans = 0
i = 0
while i < n:
    j = 1
    while i + j < n and t[i + j] < t[i] + k and j < c:
        j += 1
    i += j
    ans += 1 
print(ans)

Submission status: Wrong Answer

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

t = [0] * n
for i in range(n):
    t[i] = int(input())
t = sorted(t)
ans = 0
i = 0
while i < n:
    j = 1
    while i + j < n and t[i + j] < t[i] + k and j < c:
        j += 1
    i += j
    ans += 1 
print(t, ans)

Submission status: Wrong Answer

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

t = [0] * n
for i in range(n):
    t[i] = int(input())
t = sorted(t)
ans = 0
i = 0
while i < n:
    j = 0
    while i + j < n and t[i + j] < t[i] + k and j + 1< c:
        j += 1
    i += j
    ans += 1 
print(ans)

Submission status: Wrong Answer

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

t = [0] * n
for i in range(n):
    t[i] = int(input())
t = sorted(t)
ans = 0
i = 0
while i < n:
    j = 0
    while i + j < n and t[i + j] < t[i] + k and j < c:
        j += 1
    i += j
    ans += 1 
print(ans)

Submission status: Wrong Answer

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

t = [0] * n
for i in range(n):
    t[i] = int(input())
t = sorted(t)
ans = 0
i = 0
while i < n:
    j = 0
    while i + j < n and t[i + j] < t[i] + k and j < c:
        j += 1
    i += j
    ans += 1 
print(t, ans)

Submission status: Wrong Answer

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

t = [0] * n
for i in range(n):
    t[i] = int(input())
t = sorted(t)
ans = 0
i = 0
while i < n:
    j = 0
    while i + j < n and t[i + j] < t[i] + k:
        j += 1
    i += j
    ans += 1 
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque

n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]

t.sort()

q = deque(t)
cnt = 1
ans = 1
curr = q.popleft()

while q:
    tmp = q.popleft()
    if tmp - curr < k or cnt < c:
        cnt += 1
    else:
        ans += 1
        cnt = 1
        curr = tmp

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque

n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]

t.sort()

q = deque(t)
cnt = 1
ans = 1
curr = q.popleft()

while q:
    tmp = q.popleft()
    if cnt == 0:
        ans += 1
    if tmp - curr < k or cnt < c:
        cnt += 1
    else:
        ans += 1
        cnt = 0
        curr = tmp

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque

n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]

t.sort()

q = deque(t)
cnt = 1
ans = 1
curr = q.popleft()

while q:
    tmp = q.popleft()
    if cnt == 0:
        ans += 1
    if tmp - curr < k or cnt < c:
        cnt += 1
    else:
        ans += 1
        cnt = 0
        curr = q[0]

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
T = []
for _ in range(N):
    T.append(int(input()))
T.sort()
num = 0
lim = -1
ans = 0
for p in T:
    num += 1
    if lim == -1:
        lim = p + K
    if p > lim:
        ans += 1
        num = 0
        lim = p + K

    elif num >= C:
        ans += 1
        num = 0
        lim = -1
ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,C,K=MI()
    T=LIN(N)
    T.sort()
    angry = inf
    ans = 0
    for t in T:
        if(angry < t):
            ans += 1
            angry = inf
        
        angry = min(angry,t+K)
        # print(t,ans,angry)
    ans += angry < inf
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,C,K=MI()
    T=LIN(N)
    T.sort()
    angry = inf
    ans = 0
    for t in T:
        if(angry <= t):
            ans += 1
            angry = inf
        angry = min(angry,t+K)
        # print(t,ans,angry)
    ans += angry < inf
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

from collections import deque
n,c,k = list(map(int, input().split()))
t = deque(sorted([int(input()) for _ in range(n)]))

cnt=0
bus=[]
while t:
    t1=t.popleft()
    if not bus:
        bus.append(t1)
    elif t1-bus[0]<=k and len(bus)<c:
        bus.append(t1)

    if len(bus)>=c:
        cnt+=1
        bus.clear()

    if not bus:
        bus.append(t1)

if bus:
    cnt+=1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

from collections import deque
n,c,k = list(map(int, input().split()))
t = deque(sorted([int(input()) for _ in range(n)]))

cnt=0
bus=[]
while t:
    t1=t.popleft()
    if not bus:
        bus.append(t1)
    elif t1-bus[0]<=k or len(bus)<c:
        bus.append(t1)

    if len(bus)>=c:
        cnt+=1
        bus.clear()

    if not bus:
        bus.append(t1)

if bus:
    cnt+=1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, c, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    T = [int(input()) for i in range(n)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    T = sorted(T)
    Bus = []
    start = 0
    cnt = 0
    for t in T:
        if Bus == []:
            start = t
            Bus.append(t)
            continue
        if t <= start + k:
            Bus.append(t)
            if len(Bus) == c:
                cnt += 1
                Bus = []
        else:
            cnt += 1
            Bus = [t]
            start = t

    if len(Bus) >= 1:
        print(cnt+1)
    else:
        print(cnt)

resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, c, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    T = [int(input()) for i in range(n)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    T = sorted(T)
    Bus = []
    start = 0
    cnt = 0
    for t in T:
        if Bus == []:
            start = t
            Bus.append(t)
            continue
        if t <= start + k:
            Bus.append(t)
            if len(Bus) == c:
                cnt += 1
                Bus = []
        else:
            cnt += 1
            Bus = [t]
            start = t

    print(cnt+1)


resolve()

Submission status: Wrong Answer

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

t_s = sorted(t_input)

ans = 0
c_limit = 1
t_limit = t_s[0]*k
for i in range(n):
    t = t_input[i]
    #乗客が前の客の時間制限より大きいか、すでにバスが定員以上なら
    if t>t_limit or c>=c_limit:
        ans+=1
        c_limit=1
        t_limit = t+k
    else:
        c_limit+=1
print(ans)

Submission status: Wrong Answer

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

t_s = sorted(t_input)

ans=0
while t_s:
    x = t_s.pop(0)
    time_limit = x+c
    bus_limit = k-1
    while t_s and t_s[0]<=time_limit and bus_limit!=0:
        t = t_s.pop(0)
        bus_limit-=1
    ans+=1
print(ans)

Submission status: Wrong Answer

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

t_s = sorted(t_input)

ans=0
while t_s:
    x = t_s.pop(0)
    time_limit = x+c
    bus_limit = k
    while t_s and t_s[0]<=time_limit and bus_limit!=0:
        t = t_s.pop(0)
        bus_limit-=1
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
list = [int(input()) for _ in range(n)]
sorted_list = sorted(list)
bus = 1
customer = 1
max_hour = sorted_list[0]+k
for i in sorted_list[1:]:
  if i > max_hour or customer >= c:
    bus+=1
    customer=1
    max_hour = i+k
print(bus+1 if customer != 1 else bus)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
list = [int(input()) for _ in range(n)]
sorted_list = sorted(list)
bus = 1
customer = 1
max_hour = sorted_list[0]+k
for i in sorted_list[1:]:
  if i > max_hour or customer >= 3:
    bus+=1
    customer=1
    max_hour = i+k
print(bus+1 if customer != 1 else bus)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc011/tasks/agc011_a

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

schedule = []
for _ in range(n):
    t = int(input())
    schedule.append(t)
schedule.sort()
schedule.append(float('inf'))

def check(num, schedule, c, k):
    bus = 0
    start = 0
    p = 0
    i = 0
    while i < len(schedule):
        s = schedule[i]
        if s <= start + k:
            p += 1
            i += 1
            if p == c:
                bus += 1
                p = 0
                start = schedule[i]
        else:
            start = schedule[i]
            bus += 1
            p = 1
            i += 1
    if bus <= num:
        return True
    return False

l = 0
r = 10 ** 10
ans = float('inf')
while l <= r:
    mid = (l + r) // 2
    if check(mid, schedule, c, k):
        r = mid - 1
        ans = min(ans, mid)
    else:
        l = mid + 1

print(ans)

Submission status: Wrong Answer

Solution code:
def answer(n, c, k, ts):
    ts.sort()
    bus = 1
    _c = 0
    _k = 0
    for i in range(len(ts)):
        if (_k+k < ts[i]) or (_c == c):
            _c = 0
            _k = ts[i]
            bus += 1
        if (_k <= ts[i] and ts[i] <= (_k+k)) and (_c < c):
            _c += 1
    return bus
    
n, c, k = map(int, input().split())
ts = []
for _ in range(n):
    ts.append(int(input()))
print(answer(n, c, k, ts))

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
l=sorted([int(input()) for i in range(a)])
ans=0
now=l[0]
cur=1
for i in range(1,a):
  x=l[i]
  if cur==b:
    now=x
    cur=1
    ans+=1
  elif x-now>c:
    now=x
    ans+=1
    cur=1
  else:
    cur+=1
print(ans+min(1,cur-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=sorted(T)
ans=0
mint=0
now=0
for i,t in enumerate(T):
    if now==C:
        ans+=1
        now=1
        mint=t
    elif t-mint<=K:
        now+=1
    else:
        ans+=1
        now=1
        mint=t
    if i==N-1:
        ans+=1
print(ans)

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, c, k = LI()
t = [I() for _ in range(n)]
t.sort()
tmp = 0
cnt = 0
ans = 0
if c == 1:
    print(n)
    quit()
for i in range(n):
    if t[i] <= tmp:
        cnt += 1
        if cnt == c:
            cnt = 0
            ans += 1
            tmp = t[i] + k
    else:
        tmp = t[i] + k
        cnt = 1
        ans += 1
print(ans)

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, c, k = LI()
t = [I() for _ in range(n)]
t.sort()
i = 0
tmp = 0
cnt = 0
ans = 0
while i < n:
    if t[i] <= tmp:
        cnt += 1
        if cnt == c:
            cnt = 0
            ans += 1
            tmp = t[i] + k
    else:
        tmp = t[i] + k
        cnt = 1
        ans += 1
    i += 1
print(ans)

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, c, k = LI()
t = [I() for _ in range(n)]
t.sort()
i = 0
tmp = 0
cnt = 0
ans = 0
while i < n:
    if t[i] < tmp:
        cnt += 1
        if cnt == c:
            cnt = 0
            ans += 1
            tmp = t[i] + k
    else:
        tmp = t[i] + k
        ans += 1
    i += 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
tmp_bus = 1
bus_time = T[0] + K

for t in T[1:]:

    if tmp_bus < C and t < bus_time:
        tmp_bus += 1
    else:
        bus += 1
        bus_time = t + K
        tmp_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)])

bus = 1
bus_time = 0
tmp_bus = 0
flag = False

for t in T:

    if not flag:##のってない
        bus_time = t + K
        tmp_bus = 1
        flag = True

    else:
        if t <= bus_time:
            tmp_bus += 1
            if tmp_bus == C:
                bus += 1
                flag = False

        else:
            bus += 1
            bus_time = t + K
            tmp_bus = 1
    ##print(t,bus,tmp_bus,bus_time)

print(bus)

Submission status: Wrong Answer

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

bus = 0
bus_time = 0
tmp_bus = 0
flag = False

for i in range(N):

    t = T[i]

    if i == N-1:
        if flag:
            if t <= bus_time:
                bus += 1
            else:
                bus += 2
        else:
            bus += 1
        break

    if not flag:##のってない
        bus_time = t + K
        tmp_bus = 1
        flag = True

    else:
        if t <= bus_time:
            tmp_bus += 1
            if tmp_bus == C or i == N-1:
                bus += 1
                flag = False

        else:
            bus += 1
            bus_time = t + K
            tmp_bus = 1
    ##print(t,bus,tmp_bus,bus_time)

print(bus)

Submission status: Wrong Answer

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

bus = 1
bus_time = 0
tmp_bus = 0
flag = False

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

    if not flag:##のってない
        bus_time = t + K
        tmp_bus = 1
        flag = True

    else:
        if t <= bus_time:
            tmp_bus += 1
            if tmp_bus == C or i == N-1:
                bus += 1
                flag = False

        else:
            bus += 1
            bus_time = t + K
            tmp_bus = 1
    ##print(t,bus,tmp_bus,bus_time)

print(bus)

Submission status: Wrong Answer

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

bus = 1
bus_time = 0
tmp_bus = 0
flag = False

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

    if not flag:##のってない
        bus_time = t + K
        tmp_bus = 1
        flag = True

    else:
        if t <= bus_time:
            tmp_bus += 1
            if tmp_bus == C or i == N-1:
                bus += 1
                flag = False

        else:
            bus += 1
            bus_time = t + K
            tmp_bus = 1
    print(t,bus,tmp_bus,bus_time)

print(bus)

Submission status: Wrong Answer

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

bus = 1
bus_time = 0
tmp_bus = 0
flag = False

for t in T:

    if not flag:##のってない
        bus_time = t + K
        tmp_bus = 1
        flag = True

    else:
        if t <= bus_time:
            tmp_bus += 1
            if tmp_bus == C:
                bus += 1
                flag = False
        else:
            bus += 1
            bus_time = t + K
            tmp_bus = 1

print(bus)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

bus = 1
bus_time = T[0] + K
tmp_bus = 1
flag = True

for t in T[1:]:
    if not flag:##のってない
        bus_time = t + K
        tmp_bus = 1
        flag = True
    else:

        if t <= bus_time:
            tmp_bus += 1
            if tmp_bus == C:
                bus += 1
                flag = False
        else:
            bus += 1
            bus_time = t + K
            tmp_bus = 1

print(bus)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
n,c,k = map(int,input().split())
t = [int(input()) for _ in range(n)]
t = sorted(t)
ans = 0
now = 0
while now<n:
    if bisect_left(t,t[now]+k+1)-now>3:
        now += 3
        ans += 1
        continue
    ans += -(-(bisect_left(t,t[now]+k+1)-now)//c)
    now = bisect_left(t,t[now]+k+1)
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t = [int(input()) for _ in range(n)]
t = sorted(t)
ans = 0
g = [0]*(n+1)
now = 0
for i in range(n-1):
    if t[i]+k >= t[i+1]:
        if g[now]>=3:
            now += 1
            g[now] += 1
            continue
        g[now] += 1
    else:
        g[now] += 1
        now += 1
g[now] += 1
for i in g:
    ans += -(-i//c)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

T.sort()

bus = 0
bus_time = T[0] + K
tmp_bus = 1

for i in range(1,N):

    if i == N-1:
        if T[i] > bus_time and tmp_bus != 0:
            bus += 2
        else:
            bus += 1
        break

    if T[i] > bus_time:
        bus += 1
        bus_time = T[i+1] + K
        tmp_bus = 0
    else:
        tmp_bus += 1
    
    if tmp_bus == C:
        bus += 1
        bus_time = T[i+1] + K
        tmp_bus = 0

print(bus)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

T.sort()

bus = 0
bus_time = T[0] + K
tmp_bus = 1

for i in range(1,N):

    if i == N-1:
        if T[i] > bus_time:
            bus += 2
        else:
            bus += 1
        break

    if T[i] > bus_time:
        bus += 1
        bus_time = T[i+1] + K
        tmp_bus = 0
    else:
        tmp_bus += 1
    
    if tmp_bus == C:
        bus += 1
        bus_time = T[i+1] + K
        tmp_bus = 0

print(bus)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t = [int(input()) for _ in range(n)]
t = sorted(t)
ans = 0
g = [0]*(n+1)
now = 0
for i in range(n-1):
    if t[i]+k >= t[i+1]:
        g[now] += 1
    else:
        g[now] += 1
        now += 1
g[now] += 1
for i in g:
    ans += -(-i//c)
print(ans)

Submission status: Wrong Answer

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

T = 0
cnt = 0
ans = 0
for i in range(n):
  if cnt == 0: #誰も待っていない
    T = t[i] + k
    cnt += 1
  elif t[i] <= T:
    cnt += 1
  elif t[i] > T:
    ans += 1
    T = t[i] + k
  if cnt == c:
    ans += 1
    T = 0
    cnt = 0
if cnt != 0: ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

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

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,c,k = MI()
T = CI(n)

ls = []
for i in range(n):
    s = T[i]
    e = T[i] + k
    ls.append( [s,e] )

ls = mysort(ls,1,False)

bt = -1*INF
bus = 0
m = 0
for i in range(n):
    s = ls[i][0]
    t = ls[i][1]
    if s>bt:
        bus += 1
        bt = t
    else:
        m += 1
        if m==(c-1):
            bus += 1
            bt = t
    
print(bus)