Problem:


Score : 300 points

Problem Statement

Every day, N passengers arrive at Takahashi Airport.
The i-th passenger arrives at time T_i.

Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers.
Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport.
Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane.
For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).

When setting the departure times for buses under this condition, find the minimum required number of buses.
Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Constraints

2 \leq N \leq 100000

1 \leq C \leq 10^9

1 \leq K \leq 10^9

1 \leq T_i \leq 10^9

C, K and T_i are integers.

Input

The input is given from Standard Input in the following format:

N C K
T_1
T_2
:
T_N

Output

Print the minimum required number of buses.

Sample Input 1

5 3 5
1
2
3
6
12

Sample Output 1

3

For example, the following three buses are enough:

A bus departing at time 4.5, that carries the passengers arriving at time 2 and 3.

A bus departing at time 6, that carries the passengers arriving at time 1 and 6.

A bus departing at time 12, that carries the passenger arriving at time 12.

Sample Input 2

6 3 3
7
6
2
8
10
6

Sample Output 2

3



Sample input:
5 3 5
1
2
3
6
12


Sample output:
3

Submission status: Wrong Answer

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

T=[]
for n in range(N):
    T.append(int(input()))
    
T.sort()
# T

ans = 0
dep = 0
c = 1

for t in T:
#     print('===',t)
    if c < C and dep > t:
        c += 1
    else:
        ans += 1
        dep = t+K
        c = 1
        
#     print(ans,dep)
print(ans)

Submission status: Wrong Answer

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

T=[]
for n in range(N):
    T.append(int(input()))
    
T.sort()
# T

ans = 0
dep = 0
c = 0

for t in T:
#     print('===',t)
    if c < C and dep > t:
        c += 1
    else:
        ans += 1
        dep = t+K
        c = 0
        
#     print(ans,dep)
print(ans)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split()); a = [int(input()) for _ in range(n)]
a.sort(); t = a[0]+k; m = 0; x = 1
for i in range(n):
    if a[i] > t or m >= 3: t = a[i]+k; m = 1; x += 1
    else: m += 1
print(x)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split()); a = [int(input()) for _ in range(n)]
a.sort(); t = a[0]+k; m = 1; x = 1
for i in range(n):
    if a[i] > t or m > 3: t = a[i]+k; m = 1; x += 1
    else: m += 1
print(x)

Submission status: Wrong Answer

Solution code:
n, c, k, *t = map(int, open(0).read().split())
t.sort()
tmp = 0
cnt = 0
limit = t[0] + k
for time in t:
    if tmp == 3 or time > limit:
        limit = time + k
        tmp = 1
        cnt += 1
    else:
        tmp += 1
print(cnt + 1)

Submission status: Wrong Answer

Solution code:
n, c, k, *t = map(int, open(0).read().split())
t.sort()
tmp = 0
cnt = 0
limit = t[0] + k
for time in t:
    if tmp == 3 or time > limit:
        limit = time + k
        tmp = 1
        cnt += 1
    else:
        tmp += 1
if tmp != 0:
    print(cnt + 1)
else:
    print(cnt)

Submission status: Wrong Answer

Solution code:
n, c, k, *t = map(int, open(0).read().split())
t.sort()
tmp = 0
cnt = 0
for time in t:
    if tmp == 0:
        limit = time + k
        tmp += 1
    else:
        if time <= limit:
            tmp += 1
            if tmp == 3:
                cnt += 1
                tmp = 0
        else:
            cnt += 1
            tmp = 1
            limit = time + k

if tmp != 0:
    print(cnt + 1)
else:
    print(cnt)

Submission status: Wrong Answer

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

leave = t[0] + k
cnt = 1
ans = 0

for i in range(1,n):
    if cnt == 0 or leave < t[i]:
        ans += 1
        cnt = 1
        leave = t[i] + k
    else:
        cnt += 1

print(ans+1)

Submission status: Wrong Answer

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

leave = t[0] + k
temp = 1
ans = 0

for i in range(1,n):
    if temp == 0 or leave < t[i]:
        ans += 1
        temp = 1
        leave = t[i] + k
    else:
        temp += 1

print(ans+1)

Submission status: Wrong Answer

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

T=sorted(T)

s=T[0]
res=0
cnt=0
ans=0
if C==1:
    ans=N
else:
    for i in range(N):
        res=T[i]-s
        if res>K:
            ans+=1
            cnt,s=0,T[i]
        cnt+=1
        if cnt==C:
            ans+=1
            cnt,s=0,T[i]

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

Submission status: Wrong Answer

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

bus = 1
leave = t[0] + k
temp = 1
ans = 0

for i in range(1,n):
    if temp == 0 or leave < t[i]:
        ans += 1
        temp = 1
        leave = t[i] + k
    else:
        bus += 1

print(ans+1)

Submission status: Wrong Answer

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

bus = 0
leave = t[0] + k
temp = 1
ans = 0

for i in range(1,n):
    if temp == 0 or leave < t[i]:
        ans += 1
        temp = 1
        leave = t[i] + k
    else:
        bus += 1

print(ans+1)

Submission status: Wrong Answer

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

T=sorted(T)

s=T[0]
res=0
cnt=0
ans=0
for i in range(N):
    res=T[i]-s
    if res>K:
        ans+=1
        cnt,s=0,T[i]
    cnt+=1
    if cnt==C:
        ans+=1
        cnt,s=0,T[i]

if cnt>0:
    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)
d=[0]*N
for i in range(N-1):
    d[i+1]=T[i+1]-T[i]

s=0
cnt=0
ans=0
for i in range(N):
    s+=d[i]
    if s>K:
        ans+=1
        cnt,s=0,0
    cnt+=1
    if cnt==C:
        ans+=1
        cnt,s=0,0

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

Submission status: Wrong Answer

Solution code:
n,c,k = map(int ,input().split(" "))
t = sorted([int(input()) for i in range(n)])
total = 0
count = 0
while(count != n):
  #print(count)
  if count < n - 2:
    if t[count + 2] - t[count] <= k:
      count += 3
      total += 1
    elif t[count + 1] - t[count] <= k:
      count += 2
      total += 1
    else:
      count += 1
      total += 1
  if count == n - 2:
    if t[count + 1] - t[count] <= k:
      count += 2
      total += 1
    else:
      count += 1
      total += 1
  elif count == n - 1:
    count += 1
    total += 1
print(total)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t = sorted([int(input()) for _ in range(n)])
ans,ppl = 1,1
temp = t[0]
for v in t[1:]:
  if v-temp>k or ppl>=c:
    ans += 1
    ppl = 1
  else:
    ppl += 1
  temp = v
  #print(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N,C,K=map(int,input().split())
time=[]
for _ in range(N):
    T=int(input())
    time.append(T)
sort_time=sorted(time)
ans=1
max_N=0
max_time=sort_time[0]+K
for time in sort_time:
    if max_time==0:
        max_time=time+K
    if time<=max_time:
            max_N+=1
    else:
        ans+=1
        max_time=time+K
        max_N=1
        continue
    if max_N==C:
        ans+=1
        max_time=0
        max_N=0
print(ans)

Submission status: Wrong Answer

Solution code:
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()
busCount = 0
pCount = 0
time = 0
firstTime = 0
for i in range(N):
    time = T[i]
    if firstTime == 0:
        firstTime = T[i]
        busCount += 1
    pCount += 1
    if pCount == C:
        firstTime = 0
        pCount = 0
        continue
    if time >= firstTime + K:
        firstTime = T[i]
        busCount += 1
        pCount = 1
print(busCount)

Submission status: Wrong Answer

Solution code:
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()
busCount = 0
pCount = 0
time = 0
firstTime = 0
for i in range(N):
    time = T[i]
    if firstTime == 0:
        firstTime = T[i]
        busCount += 1
    pCount += 1
    if pCount == C:
        firstTime = 0
        pCount = 0
        continue
    if time > firstTime + K:
        firstTime = T[i]
        busCount += 1
        pCount = 1
print(busCount)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
    t[i]=int(input())
t.sort()
s=0
lt=0
ln=0

if c==1:
    print(n)
    exit()
for i in range(n):

    if i==0:
       lt=i
       ln+=1

    else:
        if t[i]-t[lt]>k:
            s+=1
            lt=i
            ln=1

        ln+=1
        if ln==c:
            s+=1
            lt=i+1
            ln=0

        #print(i, s, lt, ln)


    
if ln>0:
    s+=1

print(s)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
    t[i]=int(input())
t.sort()
s=0
lt=0
ln=0
for i in range(n):

    if i==0:
       lt=i
       ln+=1
       
    else:
        if t[i]-t[lt]>k:
            s+=1
            lt=i
            ln=1

        ln+=1
    if ln==c:
        s+=1
        lt=i+1
        ln=0

        #print(i, s, lt, ln)


    
if ln>0:
    s+=1

print(s)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
    t[i]=int(input())
t.sort()
s=0
lt=0
ln=0
for i in range(n):

    if i==0:
       lt=i
       ln+=1
    else:
        if t[i]-t[lt]>k:
            s+=1
            lt=i
            ln=1

        ln+=1
        if ln==c:
            s+=1
            lt=i+1
            ln=0

        #print(i, s, lt, ln)

"""
if lt<len(t)and t[n-1]-t[lt]>k:
    s+=1
    ln+=1
"""
    
if ln>0:
    s+=1

print(s)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
    t[i]=int(input())
t.sort()
s=0
lt=0
ln=0
for i in range(n):

    if i==0:
       lt=i
       ln+=1
    else:
        if t[i]-t[lt]>k:
            s+=1
            lt=i
            ln=1

        ln+=1
        if ln==c:
            s+=1
            lt=i+1
            ln=0

        #print(i, s, lt, ln)


if lt<len(t)and t[n-1]-t[lt]>k:
    s+=1
    ln+=1
    
if ln>0:
    s+=1

print(s)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
    t[i]=int(input())
t.sort()
s=0
lt=0
ln=0
for i in range(n):

    if i==0:
       lt=i
       ln+=1
    else:
        if t[i]-t[lt]>k:
            s+=1
            lt=i
            ln=1

        if ln==c:
            s+=1
            lt=i
            ln=0
        else:
            ln+=1
        #print(i, s, lt, ln)


if t[n-1]-t[lt]>k:
    s+=1
    ln+=1
    
if ln>0:
    s+=1

print(s)

Submission status: Wrong Answer

Solution code:
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
    t[i]=int(input())
t.sort()
s=0
lt=0
ln=0
for i in range(n):

    if i==0:
       lt=i
       ln+=1
    else:
        if t[i]-t[lt]>k:
            s+=1
            lt=i
            ln=1

        if ln==c:
            s+=1
            lt=i
            ln=0
        else:
            ln+=1
        print(i, s, lt, ln)


if t[n-1]-t[lt]>k:
    s+=1
    ln+=1
    
if ln>0:
    s+=1

print(s)

Submission status: Wrong Answer

Solution code:
n,C,T=map(int,input().split())
t=[int(input()) for i in range(n)]
t.sort()
res=t[0]+T
cnt=1
ans=0
for i in range(n):
  if t[i]<=res and cnt<C:
    cnt+=1
  elif t[i]>res or cnt==C:
    ans+=1
    res=t[i]+T
    cnt=1
print(ans+1)

Submission status: Wrong Answer

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

N,C,K = mint()
T = [int(input()) for _ in range(N)]
T.sort()
t0 = 0
i = 0
ans = 0
for t in T:
    if i==0:
        t0 = t
        i = 1
        ans += 1
    elif t-t0>K:
        t0 = t
        i = 1
        ans += 1
    else:
        i += 1
        if i==C:
            i = 0
print(ans)

Submission status: Wrong Answer

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

a = 1; t = T[0] + K; c = 1
for i in range(1,N):
    if T[i]>=t or c+1>C:
        a += 1; t = T[i] + K; c = 1
    else:
        c += 1
print(a)

Submission status: Wrong Answer

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

T.sort()

ans = 0

cnt = 0
last = T[0] + K

for t in T:
    if cnt < C and last > t:
        cnt += 1
    else:
        ans += 1
        cnt = 1
        last = t + K

if cnt > 0:
    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)]
D = deque(sorted(T))
cnt = 2
ans = 0
pre = D.popleft()
flag = False
while D:
    if cnt == C:
        cnt = 2
        pre = D.popleft()
        ans += 1
        flag = False
    else:
        d = D.popleft()
        cnt += 1
        flag = True
        if d - pre > K:
            cnt = 2
            pre = d
            ans += 1
            flag = False
if flag:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#54 A - Airport Bus
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T = sorted(T,reverse = False)

ans = 0
bus = 1
first = T[0]
for i in range(1,N):
    # バスが出発した直後のとき
    if bus == 0 and first == 0:
        first = T[i]
        bus = 1
        continue
    # バスが定員に達したとき
    if bus == C:
        ans += 1
        bus = 0
        first = 0
    # T[i] がバスに乗ることができるとき
    if T[i] <= first + K:
        bus += 1
    # T[i] がバスに乗ることができないとき
    else:
        # 新しいバスの first になる
        ans += 1
        bus = 1
        first = T[i]        
print(ans)

Submission status: Wrong Answer

Solution code:
#54 A - Airport Bus
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T = sorted(T,reverse = False)
# 最後の一人をカウントするための番兵
T.append(10**10)

ans = 0
bus = 1
first = T[0]
for i in range(1,N+1):
    # バスが出発した直後のとき
    if bus == 0 and first == 0:
        first = T[i]
        bus = 1
        continue
    # T[i] がバスに乗ることができるとき
    if T[i] <= first + K:
        bus += 1
    # T[i] がバスに乗ることができないとき
    else:
        # 新しいバスの first になる
        ans += 1
        bus = 1
        first = T[i]
        
    # バスが定員に達したとき
    if bus == C:
        ans += 1
        bus = 0
        first = 0
print(ans)

Submission status: Wrong Answer

Solution code:
#54 A - Airport Bus
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T = sorted(T,reverse = False)
# 最後の一人をカウントするための番兵
T.append(10**10)

ans = 0
bus = 1
first = T[0]
for i in range(1,N+1):
    # バスが出発した直後のとき
    if bus == 0 and first == 0:
        first = T[i]
        bus = 1
        continue
    # T[i] がバスに乗ることができるとき
    if T[i] <= first + K:
        bus += 1
    # T[i] がバスに乗ることができないとき
    else:
        # 新しいバスの first になる
        ans += 1
        bus = 1
        first = T[i]
        continue
    # バスが定員に達したとき
    if bus == C:
        ans += 1
        bus = 0
        first = 0
print(ans)

Submission status: Wrong Answer

Solution code:
#54 A - Airport Bus
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T = sorted(T,reverse = False)
# 最後の一人をカウントするための番兵
T.append(10**9+1)

ans = 0
bus = 1
first = T[0]
for i in range(1,N+1):
    # T[i] がバスに乗ることができるとき
    if (bus < C) and (T[i] <= first + K):
        bus += 1
    # T[i] がバスに乗ることができないとき
    else:
        # 新しいバスの first になる
        ans += 1
        bus = 1
        first = T[i]
        
print(ans)

Submission status: Wrong Answer

Solution code:
#54 A - Airport Bus
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T = sorted(T,reverse = False)
# 最後の一人をカウントするための番兵
T.append(10**9+1)

ans = 0
bus = 1
first = T[0]
for i in range(1,N+1):
    # T[i] がバスに乗ることができるとき
    if bus < C and T[i] <= first + K:
        bus += 1
    # T[i] がバスに乗ることができないとき
    else:
        # 新しいバスの first になる
        ans += 1
        bus = 1
        first = T[i]
        
print(ans)

Submission status: Wrong Answer

Solution code:
#54 A - Airport Bus
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T = sorted(T,reverse = False)
# 最後の一人をカウントするための番兵
T.append(10**9+1)

ans = 0
bus = 1
first = T[0]
for i in range(N+1):
    # バスが出発した直後のとき
    if bus == 0 and first == 0:
        first = T[i]
        bus = 1
        continue
    # T[i] がバスに乗ることができるとき
    if T[i] <= first + K:
        bus += 1
    # T[i] がバスに乗ることができないとき
    else:
        # 新しいバスの first になる
        ans += 1
        bus = 1
        first = T[i]
        continue
    # バスが定員に達したとき
    if bus == C:
        ans += 1
        bus = 0
        first = 0
print(ans)

Submission status: Wrong Answer

Solution code:
#54 A - Airport Bus
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T = sorted(T,reverse = False)
# 最後の一人をカウントするための番兵
T.append(10**9+1)

ans = 0
bus = 1
first = T[0]
for i in range(1,N+1):
    # バスが出発した直後のとき
    if bus == 0 and first == 0:
        first = T[i]
        bus = 1
        continue
    # T[i] がバスに乗ることができるとき
    if T[i] <= first + K:
        bus += 1
    # T[i] がバスに乗ることができないとき
    else:
        # 新しいバスの first になる
        ans += 1
        bus = 1
        first = T[i]
        continue
    # バスが定員に達したとき
    if bus == C:
        ans += 1
        bus = 0
        first = 0
print(ans)

Submission status: Wrong Answer

Solution code:
#54 A - Airport Bus
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T = sorted(T,reverse = False)

diff = []
for i in range(1,N):
    d = T[i]-T[i-1]
    diff.append(d)

ans = 1
diff_sum = 0
member = 1
for j in diff:
    # バスを出発させた直後
    if diff_sum == 0 and member == 0:
        member += 1
        continue
    # 時間差の合計
    diff_sum += j
    # 時間差が K 以下のとき
    if diff_sum <= K:
        member += 1
    # 時間差が K を超えたとき
    elif diff_sum >= K:
        ans += 1
        diff_sum = 0
        member = 0
    # バスの定員に達したとき
    if member == C:
        ans += 1
        diff_sum = 0
        member = 0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flag = 0
cnt = 0
ans = 0
for i in range(len(T)):
    time = T[i] - T[flag]
    cnt += 1
    if time > K or cnt > C:
        flag = i
        cnt = 0
        ans += 1
print(ans + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

car = 0
passenger = 0
limit = 0
for i, t in enumerate(t_sorted):
    limit = t + K
    passenger += 1
    if passenger == C:
        car += 1
        passenger = 0
        continue
    if i != N - 1:
        if t_sorted[i+1] > limit:
            car += 1
            passenger = 0
            continue
if passenger > 0:
    car += 1

print(car)

Submission status: Wrong Answer

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

t_tmp = 10**9+1
cnt = 0 
buses = 0 
for i in range(n):
  t = int(input())
  cnt +=1
  if t >= t_tmp+k or cnt >= c:
    buses += -(-cnt//c)
    cnt = 0 if t<=t_tmp+k else 1
    t_tmp = t
  
  t_tmp = min(t_tmp,t)
#  print("i:",i,"t:",t,"t_tmp+k:",t_tmp+k,"cnt:",cnt,"buses",buses)
buses += -(-cnt//c)
print(buses)

Submission status: Wrong Answer

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

t_tmp = 10**9+1
cnt = 0 
buses = 0 
for i in range(n):
  t = int(input())
  cnt +=1
  if t >= t_tmp+k or cnt >= c:
    buses += -(-cnt//c)
    cnt = 0 if t==t_tmp+k else 1
    t_tmp = t
  
  t_tmp = min(t_tmp,t)
#  print("i:",i,"t:",t,"t_tmp+k:",t_tmp+k,"cnt:",cnt,"buses",buses)
buses += -(-cnt//c)
print(buses)

Submission status: Wrong Answer

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

t_tmp = 10**9+1
cnt = 0 
buses = 0 
for i in range(n):
  t = int(input())
  cnt +=1
  if t >= t_tmp+k or cnt >= c:
    buses += -(-cnt//c)
    cnt = 0
    t_tmp = t
  t_tmp = min(t_tmp,t)
#  print(i,t,t_tmp+k,cnt,buses)
buses += -(-cnt//c)
print(buses)

Submission status: Wrong Answer

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

t_tmp = 10**9+1
cnt = 0 
buses = 0 
for i in range(n):
  t = int(input())
  cnt +=1
  if t >= t_tmp+k:
    buses += -(-cnt//c)
    cnt = 0
    t_tmp = t
  t_tmp = min(t_tmp,t)
#  print(i,t,t_tmp+k,cnt,buses,)
buses += -(-cnt//c)
print(buses)

Submission status: Wrong Answer

Solution code:


def Schedule(schedule):
    """
    :return: 複数の区間が与えられた時の重複の無い区間の選び方の最大数
    """
    schedule = sorted(schedule, key=lambda x: x[1])
    N = len(schedule)
    res = 0
    end = -float("inf")
    tmp = 0
    for i in range(N):
        if end <= schedule[i][0] or tmp == C-1:  # 重複がダメならば等号を消す
            end = schedule[i][1]  # 終点でソートされているので、自動的に可能な中で最速の終点が選ばれている
            res += 1
            tmp = 0
        else:
            tmp += 1
    return res

################################################################################

import sys
input = sys.stdin.readline

N, C, K = map(int, input().split())
schedule = []
for i in range(N):
    start = int(input())
    schedule.append((start, start + K))               # schedule = (始点、終点)

print(Schedule(schedule))

Submission status: Wrong Answer

Solution code:


def Schedule(schedule):
    """
    :return: 複数の区間が与えられた時の重複の無い区間の選び方の最大数
    """
    schedule = sorted(schedule, key=lambda x: x[1])
    N = len(schedule)
    res = 0
    end = -float("inf")

    for i in range(N):
        if end <= schedule[i][0]:  # 重複がダメならば等号を消す
            end = schedule[i][1]  # 終点でソートされているので、自動的に可能な中で最速の終点が選ばれている
            res += 1
    return res

################################################################################

import sys
input = sys.stdin.readline

N, C, K = map(int, input().split())
schedule = []
for i in range(N):
    start = int(input())
    schedule.append((start, start + K))               # schedule = (始点、終点)

print(Schedule(schedule))

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


def main():
    N, C, K = map(int, input().split())
    time = []
    for i in range(N):
        time.append(int(input()))
    time.sort()
    wait = []
    ans = 0
    for i in range(N):
        T = time[i]
        try:
            while wait[0] + K < T:
                ans += 1
                if len(wait) <= C:
                    wait.clear()
                else:
                    wait = wait[C:]
        except IndexError:
            pass
        wait.append(T)
    if wait:
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

T = []
for _ in range(N):
    T.append(int(input()))

T = sorted(T)

Standard = T[0] + K
count = 1


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

print(ans+1)

Submission status: Wrong Answer

Solution code:
a = [int(s) for s in input().split()]
N = a[0]
si = a[1]
ti = a[2]
s = [int(input()) for i in range(N)]
s = sorted(s)
X = int(0)
ans = int(0)

#全員乗るまで繰り返す
while N != X:
    #まずバスを用意して先頭を乗せる
    X += 1 
    ans += 1
    #この時点で全員乗ったら終わりにする
    if N == X:
        break
    #バスの残りsi-1枠に乗れるだけ乗せる
    #そもそも乗客がsi-1人もいない場合は残りのN-X人が上限
    print(N-X)
    temp = X
    for i in range(min([si-1,N-X])):
        if s[temp + i] <= s[temp-1] + ti:
            X += 1
        else:
            break

print(ans)

Submission status: Wrong Answer

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

for n in range(N):
    l = int(input())
    T.append(l)

T.sort()

ans = 0
V = C # current vacancies

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

ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
t = []
for _ in range(n):
    t.append(int(input()))
t.sort()
passenger = 0
bus_flag = False
bus_launch = 0
ans = 0
for i in range(n):
    if not bus_flag:
        bus_launch = t[i] + k
        bus_flag = True

    if t[i] <= bus_launch:
        passenger += 1
        if passenger == c:
            ans += 1
            bus_flag = False
            passenger = 0
    else:
        ans += 1
        bus_flag = False
        passenger = 0

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

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n ,c, k = inintm()

T = []
ans = 1

for _ in range(n):
    T.append(inint())

T.sort()

f = T[0]
cnt = 1

for i in range(1,n):
    c += 1
    if T[i] - f <= k and cnt < c:
        continue
    else:
        f = T[i]
        ans += 1
        cnt = 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n ,c, k = inintm()

T = []
ans = 1

for _ in range(n):
    T.append(inint())

T.sort()

f = T[0]
cnt = 1

for i in range(1,n):
    c += 1
    if T[i] - f <= k and cnt <= c:
        continue
    else:
        f = T[i]
        ans += 1
        cnt = 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n ,c, k = inintm()

T = []
ans = 1

for _ in range(n):
    T.append(inint())

T.sort()

f = T[0]
cnt = 1

for i in range(1,n):
    c += 1
    if T[i] - f < k and cnt <= c:
        continue
    else:
        f = T[i]
        ans += 1
        cnt = 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n ,c, k = inintm()

T = []
ans = 1

for _ in range(n):
    T.append(inint())

T.sort()

f = T[0]
cnt = 0

for i in range(1,n):
    if T[i] - f < k and cnt <= c:
        continue
    else:
        f = T[i]
        ans += 1
        cnt = 0

print(ans)

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n ,c, k = inintm()

T = []
ans = 1

for _ in range(n):
    T.append(inint())

T.sort()

f = T[0]
cnt = 0

for i in range(1,n):
    if T[i] - f < k and cnt <= c:
        continue
    else:
        f = T[i]
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n ,c, k = inintm()

T = []
ans = 1

for _ in range(n):
    T.append(inint())

T.sort()

f = T[0]
cnt = 0

for i in range(1,n):
    if T[i] - f < k and cnt <= c:
        continue
    else:
        f = T[i]
        ans += 1

print(ans)
print(T)

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n ,c, k = inintm()

T = []
ans = 1

for _ in range(n):
    T.append(inint())

T.sort()

f = T[0]

for i in range(1,n):
    if T[i] - f < k:
        continue
    else:
        f = T[i]
        ans += 1

print(ans)