結果

問題 No.5 数字のブロック
コンテスト
ユーザー splash9494
提出日時 2020-05-03 21:55:55
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 282 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 484 ms
コンパイル使用メモリ 85,700 KB
実行使用メモリ 61,192 KB
最終ジャッジ日時 2026-03-07 16:20:09
合計ジャッジ時間 1,959 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.buffer.readline

L = int(input())
N = int(input())
Ws = sorted(list(map(int, input().split())))
s = 0
cnt = 0
while True:
    s += Ws[cnt]
    cnt += 1
    if s >= L or cnt >= N:
        if s > L:
            cnt -= 1
        break
        

print(cnt)
0