結果

問題 No.5 数字のブロック
ユーザー pea vavapea vava
提出日時 2020-09-05 13:57:10
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
RE  
実行時間 -
コード長 700 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 10,472 KB
実行使用メモリ 9,244 KB
最終ジャッジ日時 2023-08-18 23:01:41
合計ジャッジ時間 3,212 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 13 ms
7,800 KB
testcase_03 RE -
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 12 ms
7,764 KB
testcase_21 AC 13 ms
7,760 KB
testcase_22 AC 12 ms
7,768 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 13 ms
7,816 KB
testcase_27 AC 13 ms
7,816 KB
testcase_28 AC 15 ms
7,888 KB
testcase_29 WA -
testcase_30 RE -
testcase_31 AC 13 ms
7,812 KB
testcase_32 AC 13 ms
7,856 KB
testcase_33 AC 13 ms
7,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

L = int(input()) #箱のサイズ
N = int(input()) #ブロックの個数
W_list = list(map(int, input().split())) #ブロックの幅サイズ
W_list.sort() #ブロック幅を昇順で並び替え
#print(W_list) #W_listソート後の表

sum = sum(W_list) #ブロック幅の総和

#ブロック幅の総和が箱のサイズより小さい場合はすべて入る
if sum <= L:
    print(N)
#ブロック幅の総和が箱のサイズより大きい場合は小さい幅のブロックから順に足し合わせて
#箱の幅を超えたら止める
elif sum > L:
    sum = 0
    for i in W_list:
        sum = sum + i
        if sum > L:
            print(W_list.index(i-1))
0