結果
問題 |
No.68 よくある棒を切る問題 (2)
|
ユーザー |
![]() |
提出日時 | 2025-04-15 23:29:29 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,265 bytes |
コンパイル時間 | 172 ms |
コンパイル使用メモリ | 82,096 KB |
実行使用メモリ | 123,528 KB |
最終ジャッジ日時 | 2025-04-15 23:30:30 |
合計ジャッジ時間 | 13,426 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 1 -- * 9 |
ソースコード
def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 L = list(map(int, input[ptr:ptr + N])) ptr += N Q = int(input[ptr]) ptr += 1 K_list = list(map(int, input[ptr:ptr + Q])) # Sort the rods in descending order to process larger rods first L.sort(reverse=True) sum_L = sum(L) results = [] for K in K_list: if K == 0: results.append(0.0) continue low = 0.0 high = sum_L / K # Initial upper bound # Perform binary search with 100 iterations for precision for _ in range(100): mid = (low + high) / 2 if mid == 0: total = 0 else: total = 0 for li in L: total += li // mid if total >= K: break # Early exit if possible if total >= K: low = mid else: high = mid results.append(low) # Format the results with sufficient precision for result in results: print("{0:.15f}".format(result)) if __name__ == "__main__": main()