Problem:


I: Starting Line

ICPC で良い成績を収めるには修行が欠かせない．うさぎは ICPC で勝ちたいので，今日も修行をすることにした．

今日の修行は，一直線上の道を走って，体力と判断力を養おうというものである．うさぎは今，スタートラインに立って長い長い道を見渡している．

道の途中にはいくつかニンジンが置かれており，うさぎはニンジンを食べると加速することができる．加速していないときのうさぎの走る速さは毎秒 U メートルであるが，ニンジンを食べることで，最後のニンジンを食べてから T 秒後までは速さが毎秒 V メートルとなる．また，うさぎはニンジンを K 個まで食べずに持っておくことができる．ニンジンを持っていても走る速さは変わらない．

ニンジンを持ったり食べたりするのに時間はかからないとして，ゴールまでの最短所要時間を求めたい．

Input

N K T U V L
D1
 ...
DN

N はニンジンの個数，L はスタートからゴールまでの距離 (メートル)，Di (1 ≤ i ≤ N) は i 番目のニンジンが置かれている場所のスタートからの距離 (メートル) である．

1 ≤ N ≤ 200，1 ≤ K ≤ N，1 ≤ T ≤ 10,000，1 ≤ U < V ≤ 10,000，2 ≤ L ≤ 10,000，0 < D1 < D2 < ... < DN < L を満たす．入力の値はすべて整数である．

Output

最短所要時間 (秒) を 1 行に出力せよ．10-6 以下の絶対誤差が許容される．

Sample Input 1

1 1 1 2 3 100
50

Sample Output 1

49.500000000

Sample Input 2

3 1 1 2 3 100
49
50
51

Sample Output 2

48.666666667



Sample input:
1 1 1 2 3 100
50


Sample output:
49.500000000

Submission status: Wrong Answer

Solution code:
N, K, T, U, V, L = map(int, input().split())
ans = 0
l = 0
t = 0
k = 0
for _ in range(N + 1):
    if _ == N:
        d = L
    else:
        d = int(input())
    length = d - l
    l = d
    if t != 0:
        if t * V > length:
            tmp = (t * V - length) / V
            ans += t - tmp
            t = tmp
            if K > k:
                k += 1
            else:
                t = T
            continue
        else:
            length = length - t * V
            ans += t
            t = 0
    if k != 0:
        k -= 1
        t = T
        if t * V > length:
            tmp = (t * V - length) / V
            ans += t - tmp
            t = tmp
            if K > k:
                k += 1
            else:
                t = T
            continue
        else:
            length = length - t * V
            ans += t
            t = 0
    ans += length / U
    if K > k:
        k += 1
    else:
        t = T
print(ans)

Submission status: Wrong Answer

Solution code:
N, K, T, U, V, L = map(int, input().split())
ans = 0
l = 0
t = 0
k = 0
for _ in range(N + 1):
    if _ == N:
        d = L
    else:
        d = int(input())
    length = d - l
    l = d
    while t > 0 or k > 0:
        if t > 0:
            if t * V >= length:
                tmp = (t * V - length) / V
                ans += t - tmp
                t = tmp
                if K > k:
                    k += 1
                else:
                    t = T
                length = 0
                break
            else:
                length = length - t * V
                ans += t
                t = 0
                if k > 0:
                    k -= 1
                    t = T
        if k > 0:
            k -= 1
            t = T
    ans += length / U
    if K > k:
        k += 1
    else:
        t = T
print(ans)

Submission status: Wrong Answer

Solution code:
N, K, T, U, V, L = map(int, input().split())
ans = 0
l = 0
t = 0
k = 0
for _ in range(N + 1):
    print(ans, l, t, k)
    if _ == N:
        d = L
    else:
        d = int(input())
    length = d - l
    l = d
    while t > 0 or k > 0:
        if t > 0:
            if t * V >= length:
                tmp = (t * V - length) / V
                ans += t - tmp
                t = tmp
                if K > k:
                    k += 1
                else:
                    t = T
                length = 0
                break
            else:
                length = length - t * V
                ans += t
                t = 0
                if k > 0:
                    k -= 1
                    t = T
        elif k > 0:
            k -= 1
            t = T
    if length > 0:
        ans += length / U
        if K > k:
            k += 1
        else:
            t = T
print(ans)

Submission status: Wrong Answer

Solution code:
carrot,maxstock,duration,normal,fast,goal = ((int(n) for n in input().split(" ")))
stack,used = [],0
for c in range(carrot):
    newcar = int(input())
    stack = list(filter(lambda x:x>newcar,stack))
    if len(stack) == 0:
        stack.append(newcar + (fast * duration))
        used += fast*duration
    elif stack[-1] >= goal:
        used += stack[-1] - goal
        break
    else:
        if len(stack) == maxstock + 1:
            used += fast*duration - (stack[0]-newcar)
            stack = list(map(lambda x:x+(fast*duration - (stack[0]-newcar)),stack))
        else:
            stack.append(stack[-1]+fast * duration)
            used += fast*duration
print((goal - used) / normal + used / fast)

Submission status: Wrong Answer

Solution code:
carrot,maxstock,duration,normal,fast,goal = ((int(n) for n in input().split(" ")))
stack,used = [],0
for c in range(carrot):
    newcar = int(input())
    stack = list(filter(lambda x:x>newcar,stack))
    
    if len(stack) == 0:
        stack.append(newcar + (fast * duration))
        used += fast*duration
    else:
        if len(stack) == maxstock + 1:
            used += fast*duration - (stack[0]-newcar)
            stack = list(map(lambda x:x+(fast*duration - (stack[0]-newcar)),stack))
            
            print(used)
        else:
            stack.append(stack[-1]+fast * duration)
            used += fast*duration
if stack[-1] > goal:
    used -= stack[-1] - goal
print((goal - used) / normal + used / fast)

Submission status: Wrong Answer

Solution code:
import sys

EPS = 1e-12

def main():
    n,k,t,u,v,l = map(int, sys.stdin.readline().split())
    carrots = [0] * 10001
    for i in range(n):
        carrots[ int(sys.stdin.readline()) ] = 1

    remain_time  = 0
    carrot_count = 0
    ans = 0
    for i in range(1,l + 1):
        #print("kyori:{}\tremain_time:{}\tcarrot_count:{}\tans:{}".format(i,remain_time,carrot_count,ans))
        # ???????????????????????????????????????
        if carrots[i] == 1:
            carrot_count += 1
        # ?????????????¶?????????????????????????
        if carrot_count > k:
            remain_time = t
            carrot_count -= 1

        if remain_time > 0 + EPS:
            # ????????????????????£???????????¶???
            if remain_time * v >= 1.0:
                ans += 1 / v
                remain_time -= 1 / v
            else:
                if carrot_count > 0:
                    ans += 1 / v
                    carrot_count -= 1
                    remain_time = t - (1 - (remain_time * v)) / v
                else:
                    ans += remain_time
                    ans += (1 - (remain_time * v)) / u
                    remain_time = 0
        else:
            remain_time = 0
            # ????????????????????£???????????¶???
            if carrot_count > 0:
                ans += 1 / v
                carrot_count -= 1
                remain_time = t - 1 / v
            else:
                ans += 1 / u

    print("{:.9f}".format(ans))



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,k,t,u,v,l = map(int,input().split())

time = 0
line = [0 for _ in range(l)]
carrots_line = [0 for _ in range(l)]
boost = False
carrots = 0
boost_dist = 0

for _ in range(n):
    carrots_line[int(input())-1] = 1

for i in range(l):
    if boost:
        line[i] = 1
        boost_dist -= 1
    else:
        pass

    if boost_dist == 0:
        if carrots_line[i] == 1:
            boost_dist = v*t
            boost = True
        else:
            if carrots > 0:
                carrots -= 1
                boost_dist = v*t
                boost = True
            else:
                boost = False
    else:
        if carrots_line[i] == 1:
            carrots = min(carrots+1, k)
            boost_dist = v*t
        boost = True

boost_run = sum(line)

ans = boost_run / v + (l - boost_run) / u

print(ans)

Submission status: Wrong Answer

Solution code:
n,k,t,u,v,l = map(int,input().split())

time = 0
line = [0 for _ in range(l)]
carrots_line = [0 for _ in range(l)]
boost = False
carrots = 0
boost_dist = 0

for _ in range(n):
    carrots_line[int(input())-1] = 1

for i in range(l):
    if boost:
        line[i] = 1
        boost_dist -= 1
    else:
        pass

    if boost_dist == 0:
        if carrots_line[i] == 1:
            boost_dist = v*t
            boost = True
        else:
            if carrots > 0:
                carrots -= 1
                boost_dist = v*t
                boost = True
            else:
                boost = False
    else:
        if carrots_line[i] == 1:
            carrots = min(carrots+1, k)
            boost_dist = v*t
        boost = True

boost_run = sum(line)

ans = boost_run / v + (l - boost_run) / u

print(ans)

Submission status: Wrong Answer

Solution code:
N,K,T,U,V,L = map(int,raw_input().split())
VT = V*T
D = [int(raw_input()) for i in range(N)] + [L]
X = D[0]
Q = D[0] + VT
i,k = 1,0
while i < N + 1:
	if D[i] == Q:
		Q += VT
		i += 1
	elif D[i] < Q:
		if k == K:
			Q = D[i] + VT
		else:
			k += 1 
		i += 1
	else:
		if k > 0:
			Q += VT
			k -= 1
		else:
			X += D[i] - Q
			Q = D[i]
			i += 1
print X*1.0/U + (L-X)*1.0/V

Submission status: Wrong Answer

Solution code:
N,K,T,U,V,L = map(int,raw_input().split())
VT = V*T
D = [int(raw_input()) for i in range(N)]
if D[-1] != L: D.append(L)
X = D[0]
Q = D[0] + VT
i,k = 1,0
while i < len(D):
	if D[i] == Q:
		Q += VT
		i += 1
	elif D[i] < Q:
		if k == K:
			Q = D[i] + VT
		else:
			k += 1 
		i += 1
	else:
		if k > 0:
			Q += VT
			k -= 1
		else:
			X += D[i] - Q
			Q = D[i]
			i += 1
print X*1.0/U + (L-X)*1.0/V

Submission status: Wrong Answer

Solution code:
N,K,T,U,V,L = map(int,raw_input().split())
R = [0]*L
D = [int(raw_input()) - 1 for i in range(N)]
dash = have = dashL = 0
for i in range(L):
	if i == dashL:
		if have == 0:
			dash = 0
		else:
			dashL = i + V*T
			have -= 1
	if i in D:
		if dash and have < K:
			have += 1
		else:
			dashL = i + V*T
			dash = 1
	if dash:
		R[i] = 1
print R.count(0)*1.0/U + R.count(1)*1.0/V

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,k,t,u,v,l = LI()
    d = [I() for _ in range(n)] + [l]
    cd = ck = ct = 0
    r = 0
    for di in d:
        while ct < di and ck > 0:
            ct += t * v
            ck -= 1
        if ct >= di:
            r += (di - cd) / v
        else:
            r += (ct - cd) / v
            r += (di - ct) / u
            ct = di
        ck += 1
        if ck > k:
            ck = k
            ct = di + t * v
        cd = di

    return '{:0.9f}'.format(r)



print(main())

Submission status: Accepted

Solution code:
N, K, T, U, V, L = map(int, input().split())
ans = 0
l = 0
t = 0
k = 0
for _ in range(N + 1):
    if _ == N:
        d = L
    else:
        d = int(input())
    length = d - l
    l = d
    while t > 0 or k > 0:
        if t > 0:
            if t * V >= length:
                tmp = (t * V - length) / V
                ans += t - tmp
                t = tmp
                if K > k:
                    k += 1
                else:
                    t = T
                length = 0
                break
            else:
                length = length - t * V
                ans += t
                t = 0
                if k > 0:
                    k -= 1
                    t = T
        elif k > 0:
            k -= 1
            t = T
    if length > 0:
        ans += length / U
        if K > k:
            k += 1
        else:
            t = T
print(ans)

Submission status: Accepted

Solution code:
carrot,maxstock,duration,normal,fast,goal = ((int(n) for n in input().split(" ")))
stack,used = [],0
for c in range(carrot):
    newcar = int(input())
    stack = list(filter(lambda x:x>newcar,stack))
    
    if len(stack) == 0:
        stack.append(newcar + (fast * duration))
        used += fast*duration
    else:
        if len(stack) == maxstock + 1:
            used += fast*duration - (stack[0]-newcar)
            stack = list(map(lambda x:x+(fast*duration - (stack[0]-newcar)),stack))
        else:
            stack.append(stack[-1]+fast * duration)
            used += fast*duration
if stack[-1] > goal:
    used -= stack[-1] - goal
print((goal - used) / normal + used / fast)

Submission status: Accepted

Solution code:
import sys

EPS = 1e-12

def main():
    n,k,t,u,v,l = map(int, sys.stdin.readline().split())
    carrots = [0] * 10001
    for i in range(n):
        carrots[ int(sys.stdin.readline()) ] = 1

    remain_time  = 0
    carrot_count = 0
    ans = 0
    for i in range(0,l):
        #print("kyori:{}\tremain_time:{}\tcarrot_count:{}\tans:{}".format(i,remain_time,carrot_count,ans))
        # ???????????????????????????????????????
        if carrots[i] == 1:
            carrot_count += 1
        # ?????????????¶?????????????????????????
        if carrot_count > k:
            remain_time = t
            carrot_count -= 1

        if remain_time > 0 + EPS:
            # ????????????????????£???????????¶???
            if remain_time * v >= 1.0:
                ans += 1 / v
                remain_time -= 1 / v
            else:
                if carrot_count > 0:
                    ans += 1 / v
                    carrot_count -= 1
                    remain_time = t - (1 - (remain_time * v)) / v
                else:
                    ans += remain_time
                    ans += (1 - (remain_time * v)) / u
                    remain_time = 0
        else:
            remain_time = 0
            # ????????????????????£???????????¶???
            if carrot_count > 0:
                ans += 1 / v
                carrot_count -= 1
                remain_time = t - 1 / v
            else:
                ans += 1 / u

    print("{:.9f}".format(ans))



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# your code goes he
#carrot 22 2298
N,K,T,U,V,L=(int(i) for i in input().split())
#r=int(input())
s=0
c=0
h=0
TV=T*V
D=[int(input()) for i in range(N)]
D.append(L)
r=D[0]
for i in range(N):
    h+=1
    if h>K:
        h-=1
        c=TV
    Ds=D[i+1]-D[i]
    if c>0:
        if Ds>c:
            Ds-=c
            s+=c
            c=0
        else:
            c-=Ds
            s+=Ds
            Ds=0
    while Ds>0 and h>0:
        h-=1
        if Ds>TV:
            Ds-=TV
            s+=TV
        else:
            c=TV-Ds
            s+=Ds
            Ds=0
    if Ds>0:
        r+=Ds
r/=U
s/=V
print(r+s)

Submission status: Accepted

Solution code:
n,k,t,u,v,l = map(int,input().split())

time = 0
line = [0 for _ in range(l)]
carrots_line = [0 for _ in range(l)]
boost = False
carrots = 0
boost_dist = 0

for _ in range(n):
    carrots_line[int(input())-1] = 1

for i in range(l):
    if boost:
        line[i] = 1
        boost_dist -= 1
    else:
        pass

    if boost_dist == 0:
        if carrots_line[i] == 1:
            boost_dist = v*t
            boost = True
        else:
            if carrots > 0:
                carrots -= 1
                boost_dist = v*t
                boost = True
            else:
                boost = False
    else:
        if carrots_line[i] == 1:
            if carrots+1 > k:
                boost_dist = v*t
            else:
                carrots += 1
        boost = True

boost_run = sum(line)

ans = boost_run / v + (l - boost_run) / u

print(ans)

Submission status: Accepted

Solution code:
N,K,T,U,V,L = map(int,raw_input().split())
R = [0]*L
D = [int(raw_input()) for i in range(N)]
dash = have = dashL = 0
for i in range(L):
	if i == dashL:
		if have == 0:
			dash = 0
		else:
			dashL = i + V*T
			have -= 1
	if i in D:
		if dash and have < K:
			have += 1
		else:
			dashL = i + V*T
			dash = 1
	if dash:
		R[i] = 1
print R.count(0)*1.0/U + R.count(1)*1.0/V

Submission status: Accepted

Solution code:
n,k,t,u,v,l = map(int,input().split())
D = []
for i in range(n):
    d = int(input())
    D.append(d)
A = [0]*l
special = 0
nomal = 0
ninzin = 0

for i in range(l):
    if i == special:
        if ninzin == 0:
            nomal = 0
        else:
            special = i + v*t
            ninzin = ninzin-1
    if i in D:
        if nomal != 0 and ninzin < k:
            ninzin += 1
        else:
            special = i + v*t
            nomal += 1
    if nomal != 0:
        A[i] = 1
print(A.count(0)/u + A.count(1)/v)

Submission status: Accepted

Solution code:
N, K, T, U, V, L = map(int, input().split())
Dlist = []
for i in range(N):
    Dlist.append(int(input()))

t = 0       # 経過時間
v = U       # 速度（初期値はU）
timer = 0
Sto = 0     # 手持ちのにんじん

for i in range(1,L+1):
    t += 1/v
    if v==V:
        timer += 1/v
    if i in Dlist:
        Sto += 1
        if v==U:
            v = V
            Sto -= 1
            timer = 0
        elif timer<T:
            if Sto>K:
                Sto -= 1
                timer = 0
        elif Sto>0:
            Sto -= 1
            timer = 0
        else:
            v = U
    else:
        if v==V:
            if Sto>0 and timer>T-1/V:
                v = V
                timer = 0
                Sto -= 1
            elif Sto==0:
                if timer>T-1/V:
                    v = U
print(f'{t:.9f}')

Submission status: Accepted

Solution code:
def get_carrot() :
    global speed, stock, U, K, i, T, accel_time
    if speed == U :
        speed = V
        accel_time = T
    elif stock == K :
        accel_time = T
    else :
        stock += 1
    i += 1

def accel_time_end() :
    global stock, accel_time, T, U, speed
    if stock > 0 :
        accel_time += T
        stock -= 1
    else :
        speed = U

N, K, T, U, V, L = map(int, input().split())
carrot=[]
for i in range(N) :
    carrot.append(int(input()))

stock = 0
time = 0
accel_time = 0
i = 0
speed = U
now = 0

while True :
    if i < N :
        if accel_time == 0 :
            time += (carrot[i] - now) / speed
            now = carrot[i]
            get_carrot()
            
        elif (carrot[i] - now) < accel_time * speed :
            time_tmp = (carrot[i] - now) / speed
            time += time_tmp
            accel_time -= time_tmp
            now = carrot[i]
            get_carrot()
        
        elif accel_time * speed < (carrot[i] - now) :
            now += accel_time * speed
            time += accel_time
            accel_time = 0
            accel_time_end()
        
        elif  accel_time * speed == (carrot[i] - now) :
            now = carrot[i]
            time += accel_time
            accel_time = 0
            accel_time_end()
            get_carrot()
        
    else :
        if ( accel_time * speed < L - now ) and accel_time != 0:
            now += accel_time * speed
            time += accel_time
            accel_time = 0
            accel_time_end()
        else :
            time += (L - now) / speed
            now += (L - now)
            print('{:.10f}'.format(time))
            break

Submission status: Accepted

Solution code:
from collections import deque
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n, k, t, u, v, l = MI()
    hp = []
    # (位置、イベントの種類、時間)として、ヒープに突っ込んでいく
    # イベントの種類は　
    # 0 ゴールする
    # 1 ニンジン効果終わる（+食べる）
    # 2 ニンジン拾う（+食べる）　
    # 時間が必要なのは1番だけで他のイベントの時は-1を突っ込んである
    heappush(hp, (l, 0, -1))
    for _ in range(n):
        d = int(input())
        heappush(hp, (d, 2, -1))
    # 「最後に速さが変わった時間、位置」と「ニンジンの数」
    time = pos = caro_n = 0
    # ニンジン効果中ならTrue
    boost = False
    cancel=deque()
    while hp:
        here, e, now = heappop(hp)
        if e == 2:
            if boost:
                if caro_n==k:
                    cancel.append(pos+v*t)
                    time += (here - pos) / v
                    pos=here
                    heappush(hp, (here + v * t, 1, time + t))
                else:
                    caro_n += 1
            else:
                time += (here - pos) / u
                pos = here
                boost = True
                heappush(hp, (here + v * t, 1, time + t))
        if e == 1:
            if cancel and here==cancel[0]:
                cancel.popleft()
                continue
            if caro_n:
                pos=here
                time=now
                caro_n -= 1
                heappush(hp, (here + v * t, 1, now + t))
            else:
                time = now
                pos = here
                boost = False
        if e == 0:
            uv = v if boost else u
            print(time + (l - pos) / uv)
            exit()

main()

Submission status: Accepted

Solution code:
n,k,t,u,v,l,*d=map(int,open(0).read().split())
ans = d[0]/u
fin = d[0]
fastend = d[0] + v*t
stack = 0
for now in d[1:]:
    while stack and fastend < now:
        ans += (fastend - fin)/v
        fin = fastend
        fastend += v*t
        stack -=1
    if fastend < now:
        ans += (fastend - fin)/v + (now - fastend)/u
        fin = now
        fastend = now + v*t
    elif fastend == now:
        ans += (fastend - fin)/v
        fin = now
        fastend = now + v*t
    elif stack == k:
        ans += (now - fin)/v
        fin = now
        fastend = now + v*t
    else:
        stack += 1
while stack and fastend <= l:
    ans += (fastend - fin)/v
    fin = fastend
    fastend += v*t
    stack -= 1
if fastend > l:
    print(ans + (l - fin)/v)
else:
    ans += (fastend - fin)/v
    fin = fastend
    print(ans + (l - fin)/u)