結果

問題 No.156 キャンディー・ボックス
ユーザー greentea011
提出日時 2019-04-09 11:25:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 432 bytes
コンパイル時間 576 ms
コンパイル使用メモリ 73,032 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-05 16:26:10
合計ジャッジ時間 1,498 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <utility>
#include <map>

int main() {
    int n,m;
    std::cin >> n >> m;
    std::multimap<int,int> mp;
    int a;
    for (int i=0;i<n;i++) {
        std::cin >> a;
        mp.insert(std::make_pair(a,1));
    }
    int cnt=0;
    for (const auto v:mp) {
        if (v.first <= m) {
            m -= v.first;
            cnt++;
        }
        else break;
    }
    std::cout << cnt << std::endl;
}
0