結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー hang_hang_clnhang_hang_cln
提出日時 2018-06-14 21:57:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 889 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 31,752 KB
最終ジャッジ日時 2023-09-13 04:17:54
合計ジャッジ時間 12,988 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
stickList = list(map(int,input().split()))
Q = int(input())
KList = list(map(int,input().split()))

def countCuttedSticks(stickList, cutLength):
    count = 0
    for stick in stickList:
        count += stick // cutLength
    
    return count
    
def main():
    for K in KList:
        low = 0
        high = max(stickList)
        if countCuttedSticks(stickList, high) == K:
            print(high)
        else:
            previousAns = -1
            while(high - low >= 10 ** -8):
                ans = (low + high) / 2
                if countCuttedSticks(stickList, ans) >= K: # 本数を少なくするために切る長さを長くする
                    low = ans
                else: # 本数を多くするために切る長さを短くする
                    high = ans
                
            print(ans)

if __name__ == '__main__':
    main()
0