結果

問題 No.156 キャンディー・ボックス
コンテスト
ユーザー Hachimori
提出日時 2015-03-03 23:26:21
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 372 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 134 ms
コンパイル使用メモリ 77,456 KB
最終ジャッジ日時 2025-12-03 14:24:35
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/usr/bin/env python
#coding:utf8

def read():
    N, M = map(int, raw_input().split())
    cList = map(int, raw_input().split())
    return M, cList


def work((M, cList)):
    ans = 0
    
    for C in sorted(cList):
        if C <= M:
            M -= C
            ans += 1
        else:
            break

    print ans


if __name__ == "__main__":
    work(read())
0