結果

問題 No.156 キャンディー・ボックス
ユーザー cureskolcureskol
提出日時 2020-03-22 14:34:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 290 bytes
コンパイル時間 1,884 ms
コンパイル使用メモリ 172,504 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 17:32:06
合計ジャッジ時間 3,212 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

signed main(){
    int n,m;cin>>n>>m;
    vector<int> v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    sort(v.begin(),v.end());
    int ans=0;
    for(int i=0;i<n;i++){
        if(v[i]<=m)ans++;
        m-=min(v[i],m);
    }
    cout<<ans<<endl;
}
0