結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー hang_hang_clnhang_hang_cln
提出日時 2018-06-14 22:04:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 777 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 11,028 KB
実行使用メモリ 30,276 KB
最終ジャッジ日時 2023-09-13 04:19:58
合計ジャッジ時間 28,101 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 967 ms
30,180 KB
testcase_01 AC 16 ms
7,796 KB
testcase_02 AC 652 ms
16,596 KB
testcase_03 AC 1,240 ms
24,208 KB
testcase_04 AC 1,305 ms
29,140 KB
testcase_05 AC 1,315 ms
29,012 KB
testcase_06 AC 1,141 ms
29,132 KB
testcase_07 AC 1,718 ms
30,124 KB
testcase_08 AC 1,726 ms
30,228 KB
testcase_09 AC 1,439 ms
30,276 KB
testcase_10 AC 1,183 ms
28,280 KB
testcase_11 AC 1,241 ms
28,124 KB
testcase_12 AC 992 ms
25,572 KB
testcase_13 AC 1,584 ms
28,596 KB
testcase_14 AC 1,636 ms
29,128 KB
testcase_15 AC 1,238 ms
26,952 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

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