Problem:


鉄道路線

複線（上りと下りが別の線路になっていてどこででもすれ違える）の鉄道路線があります。この路線には終端駅を含めて11 の駅があり、それぞれの駅と駅の間は図で示す区間番号で呼ばれています。

この路線の両方の終端駅から列車が同時に出発して、途中で停まらずに走ります。各区間の長さと2 本の列車の速度を読み込んで、それぞれの場合について列車がすれ違う区間の番号を出力するプログラムを作成してください。ただし、ちょうど駅のところですれ違う場合は、両側の区間番号のうち小さいほうの数字を出力します。また、列車の長さ、駅の長さは無視できるものとします。

Input

複数のデータセットが与えられる。各データセットは以下のような形式で与えられる。

l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,v1,v2

li (1 ≤ li ≤ 2,000) は区間 i の長さ(km)を表す整数である。v1 は区間 1 側の終端駅を出発した列車の速度(km/h)、v2 は区間 10 側の終端駅を出発した列車の速度(km/h)を表す整数である (1 ≤ v1, v2 ≤ 2,000)。

データセットの数は 50 を超えない。

Output

データセットごとに、列車がすれちがう区間の番号を１行に出力する。

Sample Input

1,1,1,1,1,1,1,1,1,1,40,60
1,1,1,1,1,3,3,3,3,3,50,50
10,10,10,10,10,10,10,10,10,10,50,49

Output for the Sample Input

4
7
6



Sample input:
1,1,1,1,1,1,1,1,1,1,40,60
1,1,1,1,1,3,3,3,3,3,50,50
10,10,10,10,10,10,10,10,10,10,50,49


Sample output:
4
7
6

Submission status: Accepted

Solution code:
while True:
    try:
        l = map(int, raw_input().split(','))
        v1, v2 = float(l[10]), float(l[11])
        a = sum(l[0:10])
        d = 0
        for i in range(10):
            d += l[i]
            t = d / v1
            if (d + t * v2) >= a:
                print i + 1
                break
    except EOFError:
        break

Submission status: Accepted

Solution code:
def f(dt, v):
    a=sum(dt)*1.0*v[0]/sum(v)
    b=0
    for i in range(len(dt)):
        b += dt[i]
        if b>= a: return i+1
    return

while True:
    try:
        dt=map(int, raw_input().split(","))
    except:
        break
    dt, v = dt[:10], dt[10:]
    print f(dt,v)

Submission status: Accepted

Solution code:
import sys

def main():
	for line in sys.stdin:
		data = map(int, line.strip().split(','))
		print analyze(data)

def analyze(data):
	lengths = data[:10]

	D = sum(lengths)

	v1 = data[10]
	v2 = data[11]

	mp = 1.0 * v1 / (v1 + v2) * D

	s = 0
	for i in xrange(10):
		s += lengths[i]
		if mp <= s:
			return i + 1

	return -1


main()

Submission status: Accepted

Solution code:
while True:
    try:
        l = map(int, raw_input().split(","))
        v1 = l.pop(10)
        v2 = l.pop(10)
        p = v1*float(sum(l))/(v1+v2)
        for i in range(10):
            p -= l[i]
            if p <= 0:
                print i+1
                break
    except:
        break

Submission status: Accepted

Solution code:
while 1:
    try:
        L = map(float, raw_input().split(','))
        sm = sum(L[:10])
        t = sm / (L[10] + L[11])
        l = t * L[10]
        i = 0
        while l > 0:
            l -= L[i]
            i += 1
        print i
    except:
        break

Submission status: Accepted

Solution code:
import bisect
try:
    while True:
        a = map(int, raw_input().split(','))
        b = [0] * 11
        for i in range(10):
            b[i + 1] = b[i] + a[i]
        print bisect.bisect_left(b, float(a[-2]) * b[-1] / (a[-1] + a[-2]))
except:
    pass

Submission status: Accepted

Solution code:
import sys

for line in sys.stdin:
	l=map(int,line.split(','))
	v=l[-2:]
	del l[-2:]

	al=0
	for i in l:
		al+=i
	al=v[0]*al/float(v[0]+v[1])

	for i in range(10):
		al-=l[i]
		if al<=0:
			print i+1
			break

Submission status: Accepted

Solution code:
while True:
    try:
        a = list(map(int, input().split(',')))
    except EOFError:
        break
    v1, v2 = a[10], a[11]
    d = [0]
    for i in range(10): d.append(a[i] + d[-1])
    x = d[10] * v1 / (v1 + v2)
    for i in range(10):
        if d[i] < x <= d[i + 1]:
            print(i + 1)
            break

Submission status: Accepted

Solution code:
while True:
    try:
        l_v = list(map(int, input().split(',')))
    except:
        break
    l = l_v[0:10]
    station = [0]
    for i in range(10):
        station.append(l[i]+station[i])
    S = station[10]
    v1 = l_v[10]
    v2 = l_v[11]
    t = S / (v1 + v2)
    v1s = v1 * t
    for i in range(10):
        if station[i] < v1s <= station[i+1]:
            print(i+1)

Submission status: Accepted

Solution code:
while True:
    try:
        lst = list(map(int, input().split(',')))
        v2 = lst.pop()
        v1 = lst.pop()
        kp = sum(lst)*v1/(v1+v2)
        l = 0
        for num, i in enumerate(lst):
            l = l + i
            if l >= kp:
                print(num + 1)
                break

    except EOFError:
        break

Submission status: Accepted

Solution code:
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    N = 10
    for line in readlines():
        *L, v1, v2 = map(int, line.split(","))
        LS = sum(L)
        vs = v1 + v2
        s = 0
        for i in range(N):
            l = L[i]
            if s * vs <= v1 * LS <= (s + l) * vs:
                write("%d\n" % (i+1))
                break
            s += l
solve()

Submission status: Accepted

Solution code:
while 1:
    try:
        datas = list(int(x) for x in input().split(","))
        v1 = datas.pop(10)
        v2 = datas.pop(10)
        p = v1 * float(sum(datas)) / (v1 + v2)
        for i in range(10):
            p -= datas[i]
            if p <= 0:
                print(i+1)
                break
    except:
        break

Submission status: Accepted

Solution code:
import sys

for line in sys.stdin:
    l = list(map(int, line.split(",")))
    total_length = sum(l[:-2])
    a_v = l[-2]
    b_v = l[-1]
    crosspointtime = total_length / (a_v + b_v)
    crosspoint = crosspointtime * a_v
    ans = 0
    for i, length in enumerate(l[:-2]):
        ans += length
        if ans >= crosspoint:
            print(i+1)
            break

Submission status: Accepted

Solution code:
while True:
    try:
        num=list(map(int, input().split(",")))
        #trainとか作る必要なかった
        train=[num[10],num[11]]
        del num[10]
        del num[-1]
            
    except:
        break
    #dis=両端の距離(全体の距離)
    dis=0
    for i in num:
        dis+=i
    #x=両電車がすれ違うまでの時間[h]
    x=dis/(train[0]+train[1])
    lon=x*train[0]
    b=0
    l=1
    while l<=10:
        b+=num[l-1]
        if b>=lon:
            print(l)
            break
        l+=1

Submission status: Accepted

Solution code:
while True:
  try:
    data = list(map(int,input().split(",")))
  except EOFError:
    break
  dist = 0.0
  for i in range(10):
    dist += data[i]
  time = dist / float(data[10]+data[11])
  pos = data[10] * time
  tmp = 0.0
  for i in range(10):
    tmp += data[i]
    if tmp >= pos:
      print(i+1)
      break

Submission status: Accepted

Solution code:
while 1:
    try:
        a = list(map(float, input().split(',')))
        dis = sum(a[:10])
        x = a[10] * dis / (a[10] + a[11])
        for i in range(0, 11):
            if x <= sum(a[:i]):
                print(i)
                break
    except:
        break

Submission status: Accepted

Solution code:
while 1:
    try: a = list(map(int, input().split(',')))
    except: break
    pos = [0]*12
    v1, v2 = a[10], a[11]
    for i in range(10): pos[i+2] = pos[i+1] + a[i]
    L = pos[11]
    pq = (L*v1) // (v1 + v2);
    pr = (L*v1) % (v1 + v2);
    i = 10
    while pq < pos[i]: i -= 1
    if pq == pos[i] and pr == 0: i -= 1
    print(i)

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin:
	inpt = map(int, line.split(','))
	rail = []
	for i in range(0, 10):
		rail.append(inpt[i])
	speed1 = inpt[10]
	speed2 = inpt[11]
	sum = 0
	for i in range(0, 10):
		sum += rail[i]
	time = float(sum)/float(speed1+speed2)
	point = time*float(speed1)
	tmp = 0
	for i in range(0, 10):
		tmp += rail[i]
		if point <= float(tmp):
			print i+1
			break

Submission status: Accepted

Solution code:
while 1:
    try:
        l=list(map(int,input().split(",")))
        v1=l[10]
        suml=sum(l[:10])
        sumv=sum(l[10:12])
        time=suml/sumv
        point=time*v1
        ans=1
        for i in l[:10]:
            if point<=i:break
            else:
                point-=i
                ans+=1
        print(ans)
    except:break

Submission status: Accepted

Solution code:
while(1):
    l = [0 for  i in range(10)]
    m = [0 for  i in range(10)]
    try:
        l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7],l[8],l[9],v1,v2 = [int(i) for i in input().split(",")] 
        for i in range(10):
            if i != 0:
                m[i] = m[i-1] + l[i]
            else:
                m[i] = l[i]
        leng = m[9]
        p = leng*v1/(v1+v2)
        for i in range(10):
            if p < m[i]:
                print(i+1)
                break
            elif abs(p - m[i]) < 10**-10:
                print(i+1
                )
                break

    except EOFError:
        break

Submission status: Accepted

Solution code:
from bisect import bisect_left as bl
while True:
    try:
        *l, v1, v2 = map(int, input().split(','))
        a = [l[0]] + [0] * 9
        for i in range(1, 10):
            a[i] = a[i-1] + l[i]
        print(bl(a,a[9]/(v1+v2)*v1) + 1)
    except:
        break

Submission status: Accepted

Solution code:
while 1:
    try:
        tmplist = list(map(int, input().split(",")))
    except:
        break

    lengthlist = tmplist[:10]
    v1 = tmplist[10]
    v2 = tmplist[11]

    lsum = sum(lengthlist)
    time = lsum / (v1 + v2)
    spot = time * v1

    le = 0
    for i, l in enumerate(lengthlist):
        le += l
        if le >= spot:
            print(i+1)
            break

Submission status: Accepted

Solution code:
import sys

for row in sys.stdin:
    row = row.strip().split(',')
    ls = list(map(int, row[:-2]))
    v1 = int(row[-2])
    v2 = int(row[-1])
    p = sum(ls) * v1 / (v1+v2)
    s = 0
    for i, l in enumerate(list(ls)):
        s += l
        if s>=p:
            print(i+1)
            break

Submission status: Accepted

Solution code:
while True:
    try: inp = input()
    except: break
    L = list(map(int, inp.split(',')))
    l, v1, v2 = L[:-2], L[-2], L[-1]
    r_sum, l_sum = sum(l), 0
    ans = 0
    for i in range(10):
        l_sum += l[i]
        r_sum -= l[i]
        if l_sum * v2 >= r_sum * v1:
            ans += i + 1
            break
    print(ans)

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin:
  xs = [int(x) for x in line.strip().split(',')]

  v2 = xs.pop()
  v1 = xs.pop()

  sumed = sum(xs)
  #print(sumed)
  #print('time', sumed/(v1+v2) )
  t = sumed/(v1+v2)
  #print('distance', t*v1)

  t = t*v1
  res = 0
  for index, x in enumerate(xs):
    t -= x
    if t == 0.0:
      res = index + 1
      break
    elif t < 0.0:
      res = index + 1
      break

  print(res)

Submission status: Accepted

Solution code:
import sys

def solve():
    for line in sys.stdin:
        inputs = list(map(int, line.split(',')))
        L = inputs[:10]
        v1, v2 = inputs[10], inputs[11]
        dL = sum(L)
        dv = v1 + v2
        hour = dL / dv
        distance = v1 * hour
        idx = 0
        while True:
            distance -= L[idx]
            if distance <= 0:
                print(idx+1)
                break
            idx += 1

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
while True:
    try:
        l = map(int, raw_input().split(","))
        v1 = l.pop(10)
        v2 = l.pop(10)
        p = v1*float(sum(l))/(v1+v2)
        for i in range(10):
            p -= l[i]
            if p <= 0:
                print i+1
                break

Submission status: Runtime Error

Solution code:
while True:
    try:
        l = map(int, raw_input().split(","))
        v1 = l.pop(10)
        v2 = l.pop(10)
        p = v1*float(sum(l))/(v1+v2)
        for i in range(10):
            p -= l[i]
            if p <= 0:
                print i+1
                break
　　　except:
      break

Submission status: Runtime Error

Solution code:
while True:
    try:
        l = map(int, raw_input().split(","))
        v1 = l.pop(10)
        v2 = l.pop(10)
        p = v1*float(sum(l))/(v1+v2)
        for i in range(10):
            p -= l[i]
            if p <= 0:
                print i+1
                break
　　　except:
      　break

Submission status: Runtime Error

Solution code:
while True:
　　try:
        l = map(int, raw_input().split(","))
        v1 = l.pop(10)
        v2 = l.pop(10)
        p = v1*float(sum(l))/(v1+v2)
        for i in range(10):
            p -= l[i]
            if p <= 0:
                print i+1
                break
　　except:
      　break

Submission status: Runtime Error

Solution code:
while True:
  try:
    line = map(int, raw_input().split(","))
  except:
    break
  sum = 0
  rail = []
  for x in line[0:10]:
    sum += x
    rail.append(sum)
  # sum: レールの総距離
  # rail: スタートから各ポイントまでの距離
  cross = sum * (line[10] * 1.0 / (line[10] + line[11]))
  for i, length in enumerate(rail):
    if cross <= length:
      print i+1
      break

Submission status: Runtime Error

Solution code:
while True:
    try:
        l = list(map(int, input().split(",")))
    except ValueError:
        break
    sum_l = sum(l[:10])
    M = sum_l*l[10]/(l[10] + l[11])
    for i in range(10):
        if M <= 0:
            print(i)
            break
        M -= l[i]

Submission status: Runtime Error

Solution code:
while True:
  t = raw_input().split(',')
  l = [int(x) for x in t[:10]]
  v = [int(x) for x in t[10:]]
  time = float(sum(l)) / float(sum(v))
  dis = time * float(v[0])

  s = 0
  for (i, x) in enumerate(l):
    s += x
    if s >= int(dis):
      print i + 1
      break

Submission status: WA: Presentation Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

for s in sys.stdin:
  print 
  d = map(float, s.split(","))
  dl,v1,v2 = d[:-2],d[-2],d[-1]
  L = sum(dl)
  x = L/(1+v2/v1)
  m = 0
  for i in range(len(dl)):
    m += dl[i]
    if m >= x: print i+1; break