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

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# 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 _ in range(n)])
ans = 0
cnt = 0
start = True
for i in range(n):
    # if i == 3:
        # print("t[i - 1] =", t[i - 1])
        # print("t[i] =", t[i])
    if start:
        cnt = 1
        start = False
        continue
    if t[i] - t[i - 1] > k:
        ans += -(-(cnt + 1) // c)
        cnt = 1
        start = True
        continue
    cnt += 1
    start = False
    # print("i = %d cnt = %d" % (i, cnt))
# print(cnt)
ans += -(-cnt // c)
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 = 1
for i in range(N-1):
    if T[i+1]-T[i]<=K and bus<C:
        bus += 1
        #print(bus)
    elif T[i+1]-T[i]>K:
        bus = 1
        ans += 1
        #print(ans)
    elif bus >= C:
        bus = 1
        ans += 1
print(ans)

Submission status: Wrong Answer

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

ans = 1
bus = 1
for i in range(N-1):
    if T[i+1]-T[i]<=K and bus<C:
        bus += 1
        #print(bus)
    elif T[i+1]-T[i]>K:
        bus = 1
        ans += 1
        #print(ans)
    elif bus >= C:
        bus = 1
        ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
arr = sorted([int(input()) for _ in range(N)])
start_t = arr[0]
bus_n = 0
ans = 0
for i in range(N):
    if arr[i] < start_t + K and bus_n < C:
        bus_n += 1
    else:
        bus_n = 1
        start_t = arr[i]
        ans += 1
if bus_n != 0:
    ans += 1
print(ans)

Submission status: Wrong Answer

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

lim = 0
ans = 0
wait = 0
for t in T:
    if t > lim:
        if wait:
            ans += 1
        lim = t + K
        wait = 1
    else:
        wait += 1
        if wait == C:
            ans += 1
            wait = 0
            lim = 0
if wait:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
t_list = []
for i in range(n):
    t_list.append(int(input()))
t_list.sort()
count = 1
current_c = []
start_t = None


for t in t_list:
    if not start_t:
        start_t = t
        current_c.append(t)
    elif len(current_c) < c:
        if start_t + k <= t:
            count += 1
            current_c = []
            start_t = t
        else:
            current_c.append(t)
    elif len(current_c) >= c:
        count += 1
        current_c = []
        start_t = t
    else:
        print("error")
print(count)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
t_list = []
for i in range(n):
    t_list.append(int(input()))
t_list.sort()
count = 1
current_c = []
start_t = None
for t in t_list:
    if not start_t:
        start_t = t
        current_c.append(t)
    elif len(current_c) < c:
        if start_t + k < t:
            count += 1
            current_c = []
            start_t = t
        else:
            current_c.append(t)
    elif len(current_c) >= c:
        count += 1
        current_c = []
        start_t = t
    else:
        print("error")
print(count)

Submission status: Wrong Answer

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

a.sort()
count=0
c_count=1
box=a[0]
for i in range(1,n):
    if c_count<c:
        if a[i]-box<=k:
            count+=1
            c_count+=1
        else:
            box=a[i]
            c_count=0
    else:
        box=a[i]
        c_count=1
    #print(count)
print(n-count)

Submission status: Wrong Answer

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

a.sort()
count=0
c_count=1
box=a[0]
for i in range(1,n):
    if c_count<c:
        if a[i]-box<k:
            count+=1
            c_count+=1
        else:
            box=a[i]
    else:
        box=a[i]
        c_count=1
    #print(count)
print(n-count)

Submission status: Wrong Answer

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

a.sort()
count=0
c_count=1
box=a[0]
for i in range(1,n):
    if c_count<c:
        if a[i]-box<=k:
            count+=1
            c_count+=1
        else:
            box=a[i]
    else:
        box=a[i]
        c_count=1
    #print(count)
print(n-count)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, c, k = map(int, input().split())
    T = sorted(list(int(input()) for _ in range(n)))
    res = 0
    cnt = 0
    dep = T[0] + k
    for i in range(n):
        if T[i] <= dep:
            cnt += 1

        if cnt == c or T[i] > dep:
            res += 1
            cnt = 0
            dep = T[i] + k

    print(res + 1)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, c, k = map(int, input().split())
    T = sorted(list(int(input()) for _ in range(n)))
    print(T)
    res = 0
    cnt = 0
    dep = T[0] + k
    for i in range(n):
        if T[i] <= dep:
            cnt += 1

        if cnt == c or T[i] > dep:
            res += 1
            cnt = 0
            dep = T[i] + k

    print(res + 1)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
import math
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, c, k = map(int, input().split())
    T = sorted(list(int(input()) for _ in range(n)), reverse=True)

    res = 0
    cnt = 0
    dep = T[0]
    for i in range(n):
        if T[i] + k >= dep:
            cnt += 1
        else:
            res += math.ceil(cnt / c)
            cnt = 1
            dep = T[i]

    print(res + math.ceil(cnt / c))


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
import math

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

print(T)

bus = 1
passenger = 0
first_passengers_time = -1
for i in T:
    print("%d %d" % (bus, i))
    if passenger == C or (passenger > 0 and first_passengers_time + K < i):
        bus += 1
        passenger = 0
        first_passengers_time = 0

    if passenger == 0:
        passenger += 1
        first_passengers_time = i
    elif passenger < C and first_passengers_time + K >= i:
        passenger += 1

print(bus)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
import math

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

bus = 1
passenger = 0
first_passengers_time = 0
for i in T:
    if passenger == C or first_passengers_time + K < i:
        bus += 1
        passenger = 0
        first_passengers_time = 0

    if passenger == 0:
        passenger += 1
        first_passengers_time = i
    elif passenger < C and first_passengers_time + K >= i:
        passenger += 1

print(bus)

Submission status: Wrong Answer

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

all_count = 0
kazu = 0
start = 0
for l in li:
    if kazu == 0 and start == 0:
        all_count += 1
        kazu += 1
        start = l
        continue
    if kazu < c and l - start <= k:
        kazu += 1
    if kazu == c:
        kazu = 0
        start = 0
        continue
    if l - start > k:
        all_count += 1
        kazu = 1
        start = l
print(all_count)

Submission status: Wrong Answer

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

bus = 1
bustime = ab[0] + k
customer = 1

for i in range(1,n):
    if customer < c and ab[i] <= bustime:
        customer += 1
        if customer == c:
            bustime = ab[i+1]+k
            customer = 0
            bus += 1
    elif bustime < ab[i]:
        bustime = ab[i]+k
        customer = 1
        bus += 1
print(bus)

Submission status: Wrong Answer

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

t.sort()

bus = 0

temp = 0 
for i in range(n):
    if temp ==0:
        bus += 1
        dis = t[i] + k
        temp = 1
    
    else:
        if t[i] <= dis and temp < c:
            temp += 1
        
        else:
            temp = 0
            
    print(temp)

print(bus+1)

Submission status: Wrong Answer

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

for T in t:
    if passenger+1 > c or T > departure_limit:
        departure_limit = T+k
        passenger = 1
        bus_cnt += 1

print(bus_cnt+1)

Submission status: Wrong Answer

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

bus = 1
bustime = ab[0] + k
customer = 1

for i in range(1,n):
    if customer < c and ab[i] < bustime:
        customer += 1
        if customer == c:
            bustime = ab[i+1]+k
            customer = 0
            bus += 1
    elif bustime <= ab[i]:
        bustime = ab[i]+k
        customer = 1
        bus += 1
print(bus)

Submission status: Wrong Answer

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

bus = 1
bustime = ab[0] + k
customer = 1

for i in range(1,n):
    if customer < c and ab[i] <= bustime:
        customer += 1
        if customer == c:
            bustime = ab[i+1]+k
            customer = 0
            bus += 1
    elif bustime < ab[i]:
        bustime = ab[i]+k
        customer = 1
        bus += 1
print(bus)

Submission status: Wrong Answer

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

bus = 1
customer = 1

for i in range(1,n):
    if customer < c and ab[i] <= ab[i-1] + k:
        customer += 1
        if customer == c:
            customer = 0
            bus += 1
    elif ab[i-1] + k < ab[i]:
        customer = 1
        bus += 1
print(bus)

Submission status: Wrong Answer

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

bus = 1
customer = 1

for i in range(1,n):
    if customer < c and ab[i] <= ab[i-1] + c:
        customer += 1
        if customer == c:
            customer = 0
            bus += 1
    elif ab[i-1] + c < ab[i]:
        customer = 1
        bus += 1
print(bus)

Submission status: Wrong Answer

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

bus = 1
customer = 1

for i in range(1,n):
    if customer < c and ab[i] <= ab[i-1] + c:
        customer += 1
        if customer == c:
            customer = 0
            bus += 1
    elif ab[i-1] + c < ab[i]:
        customer = 0
        bus += 1
print(bus)

Submission status: Wrong Answer

Solution code:
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')

# Nが乗客の人数
# Cがバスの定員
# Kが飛行機が到着から起こりだす時間
# Tが到着時刻
# T <= X <= T+Kとする必要あり
N,C,K = imn()
T = sorted([iin() for _ in range(N)])

departure_time = -1
passenger_cnt = 0
ans = 0
for i in range(N):
    if departure_time == -1: 
        departure_time = T[i] + K
        passenger_cnt += 1
        ans += 1
    else:
        if departure_time >= T[i]:
            passenger_cnt += 1 
            if passenger_cnt == C:
                departure_time = -1
                passenger_cnt = 0
        else:
            departure_time = T[i]+K
            passenger_cnt = 1
            ans += 1 
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from bisect import bisect_right as bsr
from collections import Counter as cnt
from collections import defaultdict as dd
from collections import deque
from fractions import gcd
from itertools import combinations as comb
from itertools import permutations as perm
from math import ceil, factorial, floor
from operator import itemgetter as ig
from statistics import mean as avg

sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N, C, K = input([int, 3])
    T = input([int, N])
    T.sort()
    ans, first, current = 0, -1, 0
    for t in T:
        if first == -1:
            first = t
        current += 1
        if first + K < t:
            ans += ceil(current / C)
            current = 0
            first = -1
    else:
        if 0 < current:
            ans += ceil(current / C)
    print(ans)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

Submission status: Wrong Answer

Solution code:
import sys
from bisect import bisect_right as bsr
from collections import Counter as cnt
from collections import defaultdict as dd
from collections import deque
from fractions import gcd
from itertools import combinations as comb
from itertools import permutations as perm
from math import ceil, factorial, floor
from operator import itemgetter as ig
from statistics import mean as avg

sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N, C, K = input([int, 3])
    T = input([int, N])
    T.sort()
    ans, first, current = 0, 0, 0
    for t in T:
        if first == -1:
            first = t
        current += 1
        if first + K < t:
            ans += ceil(current / C)
            current = 0
            first = -1
    else:
        if 0 < current:
            ans += ceil(current / C)
    print(ans)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,c,k = na()
t = []

for i in range(n):
    u = ni()
    t.append(u)

t.sort()

now = t[0]
p = 1
ans = 1

for i in t:
    if i-now > k or p > c:
        p = 1
        now = i
        ans += 1
    else:
        p += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,c,k = na()
t = []

for i in range(n):
    u = ni()
    t.append(u)

t.sort()

now = t[0]
p = 0
ans = 1

for i in t:
    if i-now > k or p > c:
        p = 1
        now = i
        ans += 1
    else:
        p += 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
i = 0
while i < N:
    p = 0
    lm = T[i] + K
    while i < N and p < C and lm > T[i]:
        p += 1
        i += 1
    ans += 1
print(ans)

Submission status: Wrong Answer

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

p = 0
r = 0
cnt = 1

T.sort()

for i in range(len(T)):
    if p == 0:
        p = 1
        q = T[i]
        r = 1
    elif p == 1 and q + K >= T[i] and r <= C:
        r += 1
    else:
        cnt += 1
        p = 1
        q = T[i]
        r = 1

print(cnt)

Submission status: Wrong Answer

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

p = 0
r = 0
cnt = 1

T.sort()

for i in range(len(T)):
    if p == 0:
        p = 1
        q = T[i]
        r = 1
    elif p == 1 and q + C >= T[i] and r <= K:
        r += 1
    else:
        cnt += 1
        p = 1
        q = T[i]
        r = 1

print(cnt)

Submission status: Wrong Answer

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

p = 0
r = 0
cnt = 1

T.sort()

for i in range(len(T)):
    if p == 0:
        p = 1
        q = T[i]
    elif p == 1 and q + C >= T[i] and r <= K:
        r += 1
    else:
        cnt += 1
        p = 1
        q = T[i]
        r = 1

print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest

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

    t.sort()
    ans = 1
    bus_base = t[0] + k

    for i in range(n):
        if t[i] < bus_base:
            continue
        else:
            bus_base = t[i] + k
            ans += 1

    print(ans)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 3 5
1
2
3
6
12"""
        output = """3"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """6 3 3
7
6
2
8
10
6"""
        output = """3"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

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

t.sort()
bus = 1
limit = t[0] + k
passenger = 0

"""
最初の人のリミットが来るor定員を超える→バス追加
"""
for i in range(n):
    if limit < t[i]:
        bus += 1
        passenger = 0
        if i+1 < n:
            limit = t[i] + k
    
    passenger += 1

    if passenger == c:
        bus += 1
        passenger = 0
        if i+1 < n:
            limit = t[i+1] + k

print(bus)

Submission status: Wrong Answer

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

t.sort()
bus = 1
limit = t[0] + k
passenger = 0

"""
最初の人のリミットが来るor定員を超える→バス追加
"""
for i in range(n):
    if limit < t[i]:
        bus += 1
        if i+1 < n:
            limit = t[i] + k
    
    passenger += 1

    if passenger == c:
        bus += 1
        if i+1 < n:
            limit = t[i+1] + k

print(bus)

Submission status: Wrong Answer

Solution code:
n,c,k,*t=map(int,open(0).read().split())
t=sorted(t)
cnt,ans=0,1
x=t[0]
for i in range(n):
  cnt+=1
  if t[i]-x<k or cnt>c:
    x=t[i]
    ans+=1
    cnt=1
print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k,*t=map(int,open(0).read().split())
t=sorted(t)
cnt,ans=0,0
x=t[0]
for i in range(len(t)-1):
  if t[i+1]-x<k:
    cnt+=1
  else:
    ans+=1
    x=t[i+1]
  if cnt==c:
    ans+=1
    cnt=0
    x=t[i+1]
else:
  if cnt>0:
    ans+=1
print(ans)

Submission status: Wrong Answer

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

# T = [[出発時刻, 到着時刻], ...]
T = [[0, 0] for _ in range(N)]
for i in range(N):
    t = int(input())
    T[i][0] = t + K
    T[i][1] = t

T.sort()

ans = 0
dest = T[0][0]
cap = 1
for td, ta in T[1:]:
    if ta <= dest and cap < C:
        cap += 1
        if cap == C:
            ans += 1
    elif ta <= dest and cap == C:
        dest = td
        cap = 1
    else:
        ans += 1
        dest = td
        cap = 1

if cap != C:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    T.sort()
    answer = 0
    cst = 0
    time = 0
    for i in range(N):
        if cst == C:
            answer += 1
            cst = 1
            time = T[i]
        elif T[i] - time > K:
            answer += 1
            cst = 1
            time = T[i]
        elif T[i] - time == K:
            answer += 1
            cst = 0
            time = T[i + 1]
        else:
            cst += 1

    if cst > 0:
        answer += 1
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    T.sort()
    answer = 0
    cst = 0
    time = 0
    for i in range(N):
        if cst == C:
            answer += 1
            cst = 1
            time = T[i]
        elif T[i] - time == K:
            answer += 1
            cst = 0
            time = T[i + 1]
        elif T[i] - time > K:
            answer += 1
            cst = 1
            time = T[i]
        else:
            cst += 1
    if cst > 0:
        answer += 1
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    answer = 0
    cst = 0
    time = 0
    for i in range(N):
        if cst == C:
            answer += 1
            cst = 1
            time = T[i]
        elif T[i] - time == K:
            answer += 1
            cst = 0
            time = T[i + 1]
        elif T[i] - time > K:
            answer += 1
            cst = 1
            time = T[i]
        else:
            cst += 1
    if cst > 0:
        answer += 1
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    answer = 0
    cst = 0
    time = 0
    for i in range(N):
        if cst == C:
            answer += 1
            cst = 1
            time = T[i]
        elif T[i] - time == K:
            answer += 1
            cst = 0
            time = 0
        elif T[i] - time > K:
            answer += 1
            cst = 1
            time = T[i]
        else:
            cst += 1
    if cst > 0:
        answer += 1
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

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

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

print(ans)

Submission status: Wrong Answer

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

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

for x in t:
    if not (x <= k + tmp["f"] and tmp["num"] <= c):
        ans += 1
        tmp["f"] = x
        tmp["num"] = 0
    tmp["num"] += 1

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

print(ans)

Submission status: Wrong Answer

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

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

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

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

print(ans)

Submission status: Wrong Answer

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

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

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

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

print(ans)