結果

問題 No.156 キャンディー・ボックス
ユーザー ldsyb
提出日時 2016-02-28 13:12:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 350 bytes
コンパイル時間 671 ms
コンパイル使用メモリ 63,588 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-24 12:03:18
合計ジャッジ時間 1,824 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 28 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
   int n,m;
   cin >> n >> m;
   int c[n];
   for(int i = 0;i < n;i++) cin >> c[i];
   stable_sort(c,c + n);
   for(int i = 0;i < n;i++){
      if(m < c[i]){
         cout << i << endl;
         return 0;
      }else m -= c[i];
      if(m == 0) cout << i + 1 << endl;
   }
}
0