結果

問題 No.5 数字のブロック
ユーザー 学ぶマン
提出日時 2025-07-10 20:39:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 233 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 82,104 KB
実行使用メモリ 61,356 KB
最終ジャッジ日時 2025-07-10 20:39:30
合計ジャッジ時間 3,222 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

L = int(input())
N = int(input())
W = list(map(int, input().split()))
W.sort()

SUM = 0
ans = 0
for i, w in enumerate(W):
    
    if SUM + w > L:
        ans = i
        break
    else:
        SUM += w
else:
    ans = N
print(ans)
0