結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー hang_hang_clnhang_hang_cln
提出日時 2018-06-14 22:01:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 872 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 11,144 KB
実行使用メモリ 33,484 KB
最終ジャッジ日時 2023-09-13 04:18:36
合計ジャッジ時間 28,455 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 973 ms
30,132 KB
testcase_01 AC 15 ms
7,932 KB
testcase_02 AC 631 ms
16,716 KB
testcase_03 AC 1,203 ms
24,220 KB
testcase_04 AC 1,261 ms
29,128 KB
testcase_05 AC 1,261 ms
29,216 KB
testcase_06 AC 1,120 ms
29,108 KB
testcase_07 AC 1,666 ms
30,260 KB
testcase_08 AC 1,671 ms
30,256 KB
testcase_09 AC 1,398 ms
30,204 KB
testcase_10 AC 1,141 ms
26,044 KB
testcase_11 AC 1,210 ms
28,372 KB
testcase_12 AC 959 ms
25,484 KB
testcase_13 AC 1,541 ms
28,456 KB
testcase_14 AC 1,590 ms
29,324 KB
testcase_15 AC 1,198 ms
27,136 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()))
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