Problem:


Score : 300 points

Problem Statement

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

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

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

Constraints

2 \leq N \leq 100000

1 \leq C \leq 10^9

1 \leq K \leq 10^9

1 \leq T_i \leq 10^9

C, K and T_i are integers.

Input

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

N C K
T_1
T_2
:
T_N

Output

Print the minimum required number of buses.

Sample Input 1

5 3 5
1
2
3
6
12

Sample Output 1

3

For example, the following three buses are enough:

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

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

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

Sample Input 2

6 3 3
7
6
2
8
10
6

Sample Output 2

3



Sample input:
5 3 5
1
2
3
6
12


Sample output:
3

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t = []
cnt,ans = 0,0
bt = 10**10
btl = []
for i in range(n):
    t.append(int(input()))

t.sort()

for i in range(n):
    if (t[i] >= bt)|(cnt == c):
        ans += 1
        cnt,bt = 0,10**10
    if (bt == 10**10):
        bt = t[i]+k
        cnt += 1
    else:
        cnt += 1
        
if (cnt != 0):
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t = []
cnt,ans = 0,0
bt = 10**10
btl = []
for i in range(n):
    t.append(int(input()))

t.sort()

for i in range(n):
    if (t[i] >= bt)&(cnt == c):
        ans += 1
        cnt,bt = 0,10**10
    if (bt == 10**10):
        bt = t[i]+k
        cnt += 1
    else:
        cnt += 1
        
if (cnt != 0):
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t = []
cnt,ans = 0,0
bt = 10**10
btl = []
for i in range(n):
    t.append(int(input()))

t.sort()

for i in range(n):
    if (t[i] >= bt):
        ans += 1
        btl.append(bt)
        cnt,bt = 0,10**10
    if (bt == 10**10):
        bt = t[i]+k
        cnt += 1
    else:
        cnt += 1
    if (cnt == c):
        btl.append(t[i])
        ans += 1
        cnt,bt = 0,10**10

if (cnt != 0):
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t = []
cnt,ans = 0,0
bt = 10**10
btl = []
for i in range(n):
    t.append(int(input()))

t.sort()

for i in range(n):
    if (t[i] >= bt):
        ans += 1
        btl.append(bt)
        cnt,bt = 0,10**10
    if (bt == 10**10):
        bt = t[i]+k
        cnt += 1
    else:
        cnt += 1
    if (cnt == c):
        btl.append(t[i])
        ans += 1
        cnt,bt = 0,10**9+1

if (cnt != 0):
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,c,k = map(int,input().split())
t = []
cnt,ans = 0,0
bt = 10**9+1
btl = []
for i in range(n):
    t.append(int(input()))

t.sort()

for i in range(n):
    if (t[i] >= bt):
        ans += 1
        btl.append(bt)
        cnt,bt = 0,10**9+1
    if (bt == 10**9+1):
        bt = t[i]+k
        cnt += 1
    else:
        cnt += 1
    if (cnt == c):
        btl.append(t[i])
        ans += 1
        cnt,bt = 0,10**9+1

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 x in range(N)])

ans = 0
it = 0
while it < N:
  start = T[it]
  occupancy = 0
  while it < N and occupancy < C and T[it] < start + K:
    occupancy += 1
    it += 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)]
t.sort()
ans=0
x=t[0]
y=0
for i in range(n-1):
    y+=1
    if t[i]-x>k:
        ans+=1
        x=t[i]
        y=0
    elif y==c:
        ans+=1
        x=t[i+1]
        y=0
print(ans+2 if t[-1]-x>k or y==0 else ans+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().rstrip("\n").split())
time = sorted(int(input()) for _ in range(n))

iter_ = iter(time)
top = next(iter_)
ans = 0
i = 1

try:
    while True:
        next_ = next(iter_)
        i += 1
        while top + k <= next_ and i <= c:
            next_ = next(iter_)
            i += 1
        ans += 1
        top = next_
        i = 1
except:
    print(ans)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().rstrip("\n").split())
time = (int(input()) for _ in range(n))

iter_ = iter(time)
top = next(iter_)
ans = 0
i = 1

try:
    while True:
        next_ = next(iter_)
        i += 1
        while top + k <= next_ and i <= c:
            next_ = next(iter_)
            i += 1
        ans += 1
        top = next_
        i = 1
except:
    print(ans)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
t_array = sorted([int(input()) for x in range(n)])
now_value = c
base_time = 0
now_time = 0
cnt = 1
for t in t_array:
    now_value -= 1
    if base_time == 0:
        base_time = t
    else:
        now_time = t
    if now_value < 0 or now_time-base_time >= k:
        now_value = c
        base_time = now_time
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
t_array = sorted([int(input()) for x in range(n)])
now_value = c
base_time = 0
now_time = 0
cnt = 1
for t in t_array:
    now_value -= 1
    if base_time == 0:
        base_time = t
    else:
        now_time = t
    if now_value < 0 or now_time-base_time > k:
        now_value = c
        base_time = now_time
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))

def main():
    #x,y = map(int,input().split())	x=1,y=2
    #a = input().split()	a=['1','2','3',...,'n']
    #a = list(map(int,input().split()))	a=[1,2,3,4,5,...,n]
    #li = input().split('T')	FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    #複数行の「1 2 3 4」型の入力を一配列に
    #x = sorted([list(map(int, input().split())) for _ in range(n)])
    #ソート x.sort(key=lambda y:y[1])
    # print("Yes")  print("No")  
    n,c,k = map(int,input().split())
    t=[]
    for i in range(n):
        t.append(int(input()))
    t.sort()
    ans=1
    x=[0,t[0]]
    for i in range(n):
        if x[0]==c:
            ans+=1
            x=[1,t[i]+k]
        elif t[i]<=x[1]:
            x[0]+=1
            if x[1]>t[i]+k:
                x[1]=t[i]+k
        else:
            ans+=1
            x=[1,t[i]+k]
    print(ans)
main()

Submission status: Wrong Answer

Solution code:
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))

def main():
    #x,y = map(int,input().split())	x=1,y=2
    #a = input().split()	a=['1','2','3',...,'n']
    #a = list(map(int,input().split()))	a=[1,2,3,4,5,...,n]
    #li = input().split('T')	FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    #複数行の「1 2 3 4」型の入力を一配列に
    #x = sorted([list(map(int, input().split())) for _ in range(n)])
    #ソート x.sort(key=lambda y:y[1])
    # print("Yes")  print("No")  
    n,c,k = map(int,input().split())
    t=[]
    for i in range(n):
        t.append(int(input()))
    t.sort()
    ans=1
    x=[0,t[0]]
    print(t)
    for i in range(n):
        if x[0]==c:
            ans+=1
            x=[1,t[i]+k]
        elif t[i]<=x[1]:
            x[0]+=1
            if x[1]>t[i]+k:
                x[1]=t[i]+k
        else:
            ans+=1
            x=[1,t[i]+k]
    print(ans)
main()

Submission status: Wrong Answer

Solution code:
import math
import copy
import sys
import bisect
input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))

def main():
    #x,y = map(int,input().split())	x=1,y=2
    #a = input().split()	a=['1','2','3',...,'n']
    #a = list(map(int,input().split()))	a=[1,2,3,4,5,...,n]
    #li = input().split('T')	FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    #複数行の「1 2 3 4」型の入力を一配列に
    #x = sorted([list(map(int, input().split())) for _ in range(n)])
    #ソート x.sort(key=lambda y:y[1])
    # print("Yes")  print("No")  
    n,c,k = map(int,input().split())
    t=[]
    for i in range(n):
        t.append(int(input()))
    t.sort()
    ans=1
    x=[0,t[0]]
    for i in range(n):
        if x[0]==c:
            ans+=1
            x=[0,t[i]+k]
        if t[i]<=x[1]:
            x[0]+=1
            if x[1]>t[i]+k:
                x[1]=t[i]+k
        else:
            ans+=1
            x=[1,t[i]+k]
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
import math
import copy
import sys
import bisect
input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))

def main():
    #x,y = map(int,input().split())	x=1,y=2
    #a = input().split()	a=['1','2','3',...,'n']
    #a = list(map(int,input().split()))	a=[1,2,3,4,5,...,n]
    #li = input().split('T')	FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    #複数行の「1 2 3 4」型の入力を一配列に
    #x = sorted([list(map(int, input().split())) for _ in range(n)])
    #ソート x.sort(key=lambda y:y[1])
    # print("Yes")  print("No")  
    n,c,k = map(int,input().split())
    t=[]
    for i in range(n):
        t.append(int(input()))
    t.sort()
    ans=1
    x=[0,t[0]]
    for i in range(n):
        if x[0]==c:
            ans+=1
            x=[0,t[i]+k]
        if t[i]<=x[1]:
            x[0]+=1
            if x[1]<t[i]+k:
                x[1]=t[i]+k
        else:
            ans+=1
            x=[1,t[i]+k]
    print(ans)

main()

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()
i = 0
start = 0
ans = 0
limit = C
for i in range(N - 1):
    if T[start] + K >= T[i + 1] and limit > 1 :
        limit -= 1
    elif T[start] + K < T[i + 1] and limit > 1:
        ans += 1
        limit = C
        start = i + 1
    elif T[start] + K >= T[i + 1] and limit == 1:
        ans += 1
        limit = C
        start = i + 1
if start != N:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
N,C,K=map(int,input().split())
T=[int(input()) for i in range(N)]
T.sort()
t=T[0]+K
a=1
h=1
for i in T[1:]:
    if t>i and h<C:
        h+=1
    else:
        t=i+K
        h=1
        a+=1
print(a)

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
N,C,K=map(int,input().split())
T=[int(input()) for i in range(N)]
T.sort()
t=T[0]+K
a=1
h=1
for i in T:
    if t>i and h<C:
        h+=1
    else:
        t=i+K
        h=1
        a+=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()
fstTime = 0
pasCnt= 0
ans = 1
for i in T:
  if fstTime == 0:
    fstTime = i
#  print(i - fstTime <= K , pasCnt <= C, fstTime, pasCnt)
  if i - fstTime <= K and pasCnt <= C:
    pasCnt += 1
  else:
    ans += 1
    fstTime = i
    pasCnt = 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()
fstTime = 0
pasCnt= 1
ans = 1
for i in T:
  if fstTime == 0:
    fstTime = i
#  print(i - fstTime <= K , pasCnt <= C, fstTime, pasCnt)
  if i - fstTime <= K and pasCnt + 1 <= C:
    pasCnt += 1
  else:
    ans += 1
    fstTime = i
    pasCnt = 1
print(ans)

Submission status: Wrong Answer

Solution code:
N, C, K = tuple(map(int, input().split()))
T = [int(input()) for _ in range(N)]
T = sorted(T)
base = T[0]
count = 1
ans = 0
for i in range(1, N):
    count += 1
    if (T[i] - base) > K:
        count = 0
        ans += 1
        base = T[i]

    if count == C:
        count = 0
        ans += 1
        if i + 1 < len(T):
            base = T[i+1]
        else:
            break
print(ans+1)

Submission status: Wrong Answer

Solution code:
N,C,K,*T=map(int,open(0).read().split());T.sort();B,M,L=1,0,T[0]
for t in T:
 M+=1
 if M>C or t>L:B+=1;M=1;L=t+C
print(B)

Submission status: Wrong Answer

Solution code:
N,C,K,*T=map(int,open(0).read().split());T.sort();B=M=L=0
for t in T:
 M+=1
 if M>C or t>L:B+=1;M=0;L=t+C
print(B+(M>0))

Submission status: Wrong Answer

Solution code:
N,C,K,*T=map(int,open(0).read().split());T.sort();B=M=L=0
for t in T:
 M+=1
 if M>C or t>L:B+=1;M=0;L=t+C
print(B)

Submission status: Wrong Answer

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

B=0
L=0
ans=0
for T in TT:
  if B==0:
    L=T+K
    B=C-1
    ans+=1
  else:
    if L>T:
      B-=1
    else:
      L=T+K
      B=C-1
      ans+=1
  #print(T,B,L)
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()
#print(T)

n=0
l=0
ans=0
for i in range(N):
  if n==0:
    n=C-1
    l=T[i]+K
    ans+=1
  else:
    if T[i]<l:
      n-=1
    else:
      n=C-1
      l=T[i]+K
      ans+=1
  #print(n,l,T[i])
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()
#print(T)

n=0
l=0
ans=0
for i in range(N):
  if n==0:
    n=C
    l=T[i]+K
    ans+=1
  else:
    if T[i]<l:
      n-=1
    else:
      n=C
      l=T[i]+K
      ans+=1
  #print(n,l,T[i])
print(ans)

Submission status: Wrong Answer

Solution code:
N, C, K = tuple(map(int, input().split()))
T = [int(input()) for _ in range(N)]
T = sorted(T)
diff = 0
count = 0
ans = 0
for i in range(N-1):
    diff += (T[i+1] - T[i])
    if count <= C and diff <= K:
        count += 1
        continue
    else:
        diff = 0
        ans += 1
print(count)

Submission status: Wrong Answer

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

bus = 0
member = 1
time = T[0] + K

for i in range(1, N):
    member += 1
    if time < T[i]:
        bus += 1
        member = 1
        time = T[i] + K
    elif time > T[i] and member >= C:
        if C % member == 0:
            bus += C // member
        else:
            bus += C // member + 1
        member = 0
        time = T[i+1] + K
    else:
        pass

if member > 0:
    bus += 1

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 = sorted(t)
l = []
bus = 0

for i in range(n):
  if not l:
    l.append(t[i])
    continue
  if l[0] + k < t[i]:
    l = []
    bus += 1
  else:
    l.append(t[i])
    if len(l) is c:
      l = []
      bus += 1

if l:
  bus += 1
print(bus)

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
Ts = []
for i in range(N):
  T = int(input())
  Ts.append(T)
Ts.sort()
r = 0
i = 0
while i < N:
  Imin = i
  Tmin = Ts[Imin]
  while i < N:
    if i < Imin+C and Ts[i] < Tmin+K:
      i += 1
    else:
      break
  r += 1
print(r)

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
Ts = []
for i in range(N):
  T = int(input())
  Ts.append(T)
Ts.sort()
r = 1
i = 0
while i < N:
  Imin = i
  Tmin = Ts[Imin]
  while i < N:
    if i < Imin+C and Ts[i] <= Tmin+K:
      i += 1
    else:
      break
  r += 1
  i += 1
print(r)

Submission status: Wrong Answer

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

def main():
    N,C,K = map(int,input().split())
    T = []
    for _ in range(N):
        T.append(int(input()))
    T.sort()
    q = collections.deque(T)

    ans = 1
    n = 1
    t0 = q.popleft()
    while q:
        t1 = q.popleft()
        if t1 < t0 + K and n < C:
            n += 1
        else:
            ans += 1
            n = 1
            t0 = t1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,C,K,*T=map(int,open(0).read().split());T.sort();B=M=L=0
for t in T:
 if M>C or t>L:B+=1;M=0;L=t+C
 M+=1
print(B)

Submission status: Wrong Answer

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

count = 0
passengers = 0
border = 0
for i in range(n):
    if border == 0:
        border = times[i] + k
    if c > passengers and border >= times[i]:
        passengers += 1
        if passengers == c:
            count += 1
            passengers = 0
            border = 0
    elif border < times[i]:
        count += 1
        passengers += 1
        border = 0

print(count + 1 if passengers > 0 else count)

Submission status: Wrong Answer

Solution code:
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, C, K = map(int, input().split())
        T = [int(input()) for _ in range(N)]

        T.sort()
        bus = 1
        p = 1
        start = T[0]
        for i in range(1, N):
            p += 1
            if T[i] - start >= K or p >= C:
                bus += 1
                p = 1
                start = T[i]

        print(bus)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Wrong Answer

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

T.sort()
bus = 1
p = 1
start = T[0]
for i in range(1, N - 1):
    p += 1
    if T[i + 1] - start > K or p + 1 > C:
        bus += 1
        p = 0
        start = T[i + 1]

print(bus)

Submission status: Wrong Answer

Solution code:
import sys
input==sys.stdin.readline
inf=float("inf")
n,c,k=map(int,input().split())
T=[int(input()) for _ in range(n)]
T.sort()
t=T[0]+k
m=1
ans=0
for i in range(1,n):
    if T[i]==t and m+1<=c:
        ans+=1
        t=inf
        m=0
    elif m+1==c:
        ans+=1
        t=inf
        m=0
    elif T[i]>t:
        ans+=1
        t=T[i]+k
        m=1
    else:
        t=T[i]+k
        m+=1
if m:
    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()

cnt = 1
p = 0

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

Submission status: Wrong Answer

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

T.sort()

cnt = 1
p = 0

for i in range(N-1):
    if T[i+1]-T[i] > K:
        cnt += 1
        continue
    else:
        p += 1
        if p == C:
            p = 0
            cnt += 1
            continue
            
print(cnt)

Submission status: Wrong Answer

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

    ans = 0
    tt = t[0]
    cc = 1
    for i in range(1, n):
        if tt + k < t[i] or c == cc:
            tt = t[i]
            ans += 1
            c=0

        cc += 1

    print(ans+1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    ans = 0
    tt = t[0]
    cc = 1
    for i in range(1, n):
        if tt + k < t[i] or c == cc:
            tt = t[i]
            ans += 1

        cc += 1

    print(ans+1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    ans = 0
    tt = t[0]
    cc = 1
    for i in range(1, n):
        if tt + k > t[i] or cc == c:
            tt = t[i]
            ans += 1
            cc = 1
        else:
            cc += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, C, K = map(int, input().split())
T = []
for i in range(N):
  T.append(int(input()))
T = sorted(T)
car = 0
fast = 0
ps = 0
for i in range(N):
  if ps == 0:
    ps = 1 #乗客
    fast = T[i] #最初の乗客の待ち始めた時間
    car += 1 #車両数
  elif ps > C or fast + K > T[i]:
    ps = 1
    fast = T[i]
    car += 1
  else:
    ps += 1
print(car)

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()
counter = 0
while len(T) > 0:
  if len(T) == 1:
    T.pop()
    counter += 1
  else:
    c = 1
    while c <= len(T)-1:
      if T[c] - T[0] < K:
        c += 1
      else:
        break
  
    del T[:min(c,C)]
    counter += 1

print(counter)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq, bisect


def solve(N: int, C: int, K: int, T: "List[int]"):
    c = 0
    res = 0
    while c < N:
        p = min(N-1, c + C)
        idx = bisect.bisect_right(T, T[c]+K)
        # print(p, idx)
        c = min(idx, p) + 1
        res += 1
    print(res+1)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    T = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, C, K, T)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq, bisect


def solve(N: int, C: int, K: int, T: "List[int]"):
    c = 0
    res = 0
    while c < N-1:
        p = min(N-1, c + C)
        idx = bisect.bisect_right(T, T[c]+K)
        # print(p, idx)
        c = min(idx, p)
        res += 1
    print(res+1)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    T = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, C, K, T)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
nums ,limit ,wait = map(int, input().split())
nums_ary = [0 for i in range(nums)]

for i in range(nums):
    nums_ary[i] = int(input())

nums_ary.sort()
nums_ary.append(10000000000000)
count = 0
i = 0
while i < nums:
    time = nums_ary[i]
    for x in range(limit):
        print(i,count,nums_ary[i])
        if not time <= nums_ary[i] <= time + wait:
            count += 1
            break
        i += 1
    else:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys
nums ,limit ,wait = map(int, input().split())
nums_ary = [0 for i in range(nums)]
time = 0
count = 0
a = -1

for i in range(nums):
    nums_ary[i] = int(input())

nums_ary.sort()

while a < nums :
    a += 1
    if a == nums:
        count += 1
        break
    time = nums_ary[a]
    b = 0

    while a < nums and b < limit-1:
        if a == nums :
            count += 1
            print(count)
            sys.exit()
        if not time <= nums_ary[a] <= time+wait:
            count += 1
            break
        a += 1
        b += 1
    else:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
nums ,limit ,wait = map(int, input().split())
nums_ary = [0 for i in range(nums)]
nums_ary.append(10000000000)
time = 0
count = 0
a = -1

for i in range(nums):
    nums_ary[i] = int(input())

nums_ary.sort()

while a < nums :
    a += 1
    time = nums_ary[a]
    b = 0
    while a < nums and b < limit-1:
        if not time <= nums_ary[a] <= time+wait:
            count += 1
            break
        a += 1
        b += 1
    else:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
nums ,limit ,wait = map(int, input().split())
nums_ary = [0 for i in range(nums)]
nums_ary.append(10000000000)
time = 0
count = 0
a = -1

for i in range(nums):
    nums_ary[i] = int(input())

nums_ary.sort()

while a < nums :
    a += 1
    time = nums_ary[a]
    b = 0
    while a < nums and b < limit-1:
        if not time <= nums_ary[a] < time+wait:
            count += 1
            break
        a += 1
        b += 1
    else:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
nums ,limit ,wait = map(int, input().split())
nums_ary = [0 for i in range(nums)]
nums_ary.append(1000000)
time = 0
count = 0
check = 0
a = -1

for i in range(nums):
    nums_ary[i] = int(input())

nums_ary.sort()

while a < nums :
    a += 1
    time = nums_ary[a]
    b = 0
    while a <= nums and b < limit-1:
        if not time <= nums_ary[a] < time+wait:
            count += 1
            break
        a += 1
        b += 1
    else:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:

import bisect
n, c, k = [ int(v) for v in input().split() ]
passenger_list = sorted([ int(input()) for i in range(n) ])
passenger_list_2 = [ None for i in range(n)]
pointer = 0
ans = 0

for i in range(n):
    passenger_list_2[i] = min(i+c, bisect.bisect_left(passenger_list,passenger_list[i]+k) )

pointer = 0
ans = 0
while pointer < n:
    pointer = passenger_list_2[pointer]
    ans += 1
print(ans)

Submission status: Wrong Answer

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

pointer = 0
ans = 0
while pointer < n-1:
    p = 0
    for i in range(min(c,n-1-pointer)):
        if passenger_list[pointer+i] <= k or pointer+i != n:
            p += 1
        else:
            break
    pointer += p
    ans += 1


print(ans+1)

Submission status: Wrong Answer

Solution code:
from collections import deque
n,c,k,*t = map(int,open(0).read().split())
d = deque(sorted(t)+[float("inf")])
f = d[0]
cnt = ans = 0
while d:
	if d[0]-f <= k:
		del d[0]
		cnt += 1
		if cnt == c:
			f = d[0]
			cnt = 0
			ans += 1
	else:
		f = d.popleft()
		cnt = 0
		ans += 1
print(ans-(c==1))

Submission status: Wrong Answer

Solution code:
from collections import deque
n,c,k,*t = map(int,open(0).read().split())
d = deque(sorted(t)+[float("inf")])
f = d[0]
cnt = ans = 0
while d:
	if d[0]-f <= k:
		del d[0]
		cnt += 1
		if cnt == c:
			f = d.popleft()
			cnt = 0
			ans += 1
	else:
		f = d.popleft()
		cnt = 0
		ans += 1
print(ans-(c==1))

Submission status: Wrong Answer

Solution code:
n, c, k = map(int, input().split())
T = sorted([int(input()) for i in range(n)])
ans = 0
last = 0
jokyaku = 0
for t in T:
    if t <= last:
        jokyaku += 1
        if jokyaku == c:
            jokyaku = 0
            last = 0
        else:
            last = t + k
    else:
        jokyaku = 1
        ans += 1
        last = t + k
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import defaultdict
input = sys.stdin.readline

n, c, k = map(int, input().split())
bus_count = 0
vacant_seat = 0
dic = defaultdict(int)
limit = 0

for _ in range(n):
    dic[int(input())] += 1

keys = sorted(list(dic.keys()))

for key in keys:
    if key > limit or vacant_seat == 0:
        bus_count += math.ceil(dic[key]/c)
        vacant_seat = c - (dic[key] % c)
        limit = key + k

    else:
        count = dic[key] - vacant_seat
        if count <= 0:
            vacant_seat = -count
            continue
        else:
            bus_count += math.ceil(count/c)
            vacant_seat = c - (count % c)
            limit = key + k

print(bus_count)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import defaultdict
input = sys.stdin.readline

n, c, k = map(int, input().split())
bus_count = 0
vacant_seat = 0
dic = defaultdict(int)
limit = 100000000

for _ in range(n):
    dic[int(input())] += 1

keys = sorted(list(dic.keys()))

for key in keys:
    if vacant_seat == 0 or key > limit:
        bus_count += math.ceil(dic[key]/c)
        vacant_seat = c - (dic[key] % c)
        limit = key + k

    else:
        count = dic[key] - vacant_seat
        if count <= 0:
            vacant_seat = -count
            continue
        else:
            bus_count += math.ceil(count/c)
            vacant_seat = count % c
            limit = key + k

print(bus_count)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import defaultdict
input = sys.stdin.readline

n, c, k = map(int, input().split())
bus_count = 0
vacant_seat = 0
dic = defaultdict(int)
limit = 100000000

for _ in range(n):
    dic[int(input())] += 1

for key in dic.keys():
    if vacant_seat == 0 or key > limit:
        bus_count += math.ceil(dic[key]/c)
        vacant_seat = key % c
        limit = key + k

    else:
        count = dic[key] - vacant_seat
        if count <= 0:
            vacant_seat = -vacant_seat
            continue
        else:
            bus_count += math.ceil(count/c)
            vacant_seat = count % c
            limit = key + k

print(bus_count)