結果
問題 | No.2009 Drunkers' Contest |
ユーザー |
![]() |
提出日時 | 2020-11-19 02:21:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 194 ms / 2,000 ms |
コード長 | 594 bytes |
コンパイル時間 | 273 ms |
コンパイル使用メモリ | 81,664 KB |
実行使用メモリ | 146,472 KB |
最終ジャッジ日時 | 2024-06-27 15:59:43 |
合計ジャッジ時間 | 9,021 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 54 |
ソースコード
from math import sqrtdef calc(N, A, B):AA = [0]BB = [0]for a, b in zip(A, B):AA.append(AA[-1] + a)BB.append(BB[-1] + b)L = [(0, 0)]for i in range(N)[::-1]:sa, sb = A[i], B[i]while sa * L[-1][1] - sb * L[-1][0] > 0:sa += L[-1][0]sb += L[-1][1]L.pop()L.append((sa, sb))ans = 0for a, b in L[1:]:ans += sqrt(a * b) * 2 if a > b else a + breturn ansN = int(input())A = [int(a) for a in input().split()]B = [int(a) for a in input().split()]print(calc(N, A, B))