0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ABC223 C - Doukasen が解けた

Last updated at Posted at 2021-10-19

abc223c_1.png
abc223c_2.png
abc223c_3.png

本番当日は気が付かなかったけど、
距離/速さ = 時間、だよね。
ってことは全てが燃えきるまでの時間/2 の時間までに
左から何センチまで燃えるか分かれば回答になるよね。

abc223c.py
N = int(input())
lis = []
sum_time = 0

for _ in range(N):
    a,b = map(int,input().split())
    lis.append([a,b,a/b])
    sum_time += a/b
target_time = sum_time/2

cnt = 0
memo = 0
rest_time = 0
for i in range(N):
    if cnt + lis[i][2] == target_time:
        memo = i+1
        rest_time = target_time-(cnt+lis[i][2])
        break
    elif cnt + lis[i][2] > target_time:
        memo = i
        rest_time = target_time-cnt
        break
    else:
        cnt += lis[i][2]
ans = 0
for j in range(memo):
    ans += lis[j][0]

print("{:.5f}".format(ans + rest_time*lis[memo][1]))

ちょっと大きくなったけど、通った。
修行してまた来よう、その時はもっとシンプルに書けるはず

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?