結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー hang_hang_clnhang_hang_cln
提出日時 2018-06-14 23:15:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 3,287 ms / 5,000 ms
コード長 764 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 33,400 KB
最終ジャッジ日時 2024-04-26 00:33:35
合計ジャッジ時間 54,974 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,861 ms
33,400 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 1,214 ms
19,036 KB
testcase_03 AC 2,334 ms
26,580 KB
testcase_04 AC 2,663 ms
29,364 KB
testcase_05 AC 2,630 ms
29,360 KB
testcase_06 AC 2,336 ms
29,356 KB
testcase_07 AC 3,287 ms
32,660 KB
testcase_08 AC 3,281 ms
32,660 KB
testcase_09 AC 2,792 ms
32,660 KB
testcase_10 AC 2,454 ms
27,652 KB
testcase_11 AC 2,479 ms
28,420 KB
testcase_12 AC 2,014 ms
26,968 KB
testcase_13 AC 2,975 ms
31,156 KB
testcase_14 AC 3,116 ms
32,064 KB
testcase_15 AC 2,428 ms
29,532 KB
testcase_16 AC 1,882 ms
29,364 KB
testcase_17 AC 1,760 ms
29,344 KB
testcase_18 AC 1,743 ms
29,352 KB
testcase_19 AC 1,705 ms
32,660 KB
testcase_20 AC 1,689 ms
32,652 KB
testcase_21 AC 1,693 ms
32,664 KB
testcase_22 AC 100 ms
27,652 KB
testcase_23 AC 1,635 ms
28,672 KB
testcase_24 AC 29 ms
10,880 KB
testcase_25 AC 97 ms
11,264 KB
testcase_26 AC 55 ms
11,008 KB
testcase_27 AC 47 ms
10,752 KB
testcase_28 AC 562 ms
14,308 KB
testcase_29 AC 301 ms
12,540 KB
testcase_30 AC 100 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

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
        for i in range(100):
            ans = (low + high) / 2
            if countCuttedSticks(stickList, ans) >= K: # 本数を少なくするために切る長さを長くする
                low = ans
            else: # 本数を多くするために切る長さを短くする
                high = ans
            
        print(ans)

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