結果

問題 No.5 数字のブロック
ユーザー colognecologne
提出日時 2022-01-20 15:22:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 319 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 82,228 KB
実行使用メモリ 60,160 KB
最終ジャッジ日時 2024-11-23 20:02:39
合計ジャッジ時間 3,041 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline


def main():
    L = int(input())
    N = int(input())
    *W, = map(int, input().split())
    W.sort()

    ans = 0
    for i in W:
        if L >= i:
            L -= i
            ans += 1
        else:
            break
    print(ans)


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