結果

問題 No.156 キャンディー・ボックス
ユーザー Mizuno
提出日時 2024-10-14 21:25:57
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 354 bytes
コンパイル時間 1,540 ms
コンパイル使用メモリ 98,728 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-14 21:26:04
合計ジャッジ時間 2,646 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    
    int n,m;
    cin >> n >> m;
    int c[n];
    
    for(int i = 0; i < n; i++)cin >> c[i];
    
    sort(c,c+n);
    int count = 0;
    for(int it:c) {
        if(it <= m){
            m -= it;
            count++;
        }else break;
    }
    cout << count;
    
}
0