結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー lam6er
提出日時 2025-04-15 23:32:56
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,156 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 81,676 KB
実行使用メモリ 123,628 KB
最終ジャッジ日時 2025-04-15 23:34:10
合計ジャッジ時間 13,064 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

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
    L.sort(reverse=True)  # Sort in descending order
    max_L = L[0] if N > 0 else 0
    Q = int(input[ptr])
    ptr += 1
    K_list = list(map(int, input[ptr:ptr+Q]))
    
    for K in K_list:
        if K == 0:
            print("0.0")
            continue
        low = 0.0
        high = max_L
        for _ in range(100):
            mid = (low + high) / 2
            if mid == 0:
                cnt = 0
            else:
                cnt = 0
                for li in L:
                    if li < mid:
                        break  # Remaining elements are smaller, so break early
                    add = li // mid
                    cnt += add
                    if cnt >= K:
                        break  # Early exit if count exceeds K
            if cnt >= K:
                low = mid
            else:
                high = mid
        # Format the output to required precision
        print("{0:.15f}".format(low))
        
if __name__ == "__main__":
    main()
0