結果

問題 No.156 キャンディー・ボックス
ユーザー R N
提出日時 2020-09-11 21:19:55
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 352 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-12-26 20:07:33
合計ジャッジ時間 2,657 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding=utf-8:

n, m = map(int,input().split())
c = list(map(int,input().split()))
c.sort(reverse=False)
i = 0
while True:
    if m > c[i]:
        m -= c[i]
        c[i] = "0"
        i += 1
    elif m == c[i]:
        m -= c[i]
        c[i] = "0"
        break
    elif m < c[i]:
        m -= c[i]
        c[i] -= m
        break
print(c.count("0"))
0