結果

問題 No.156 キャンディー・ボックス
ユーザー chacoder1chacoder1
提出日時 2021-03-13 12:06:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 2,031 ms
コンパイル使用メモリ 194,240 KB
最終ジャッジ日時 2025-01-19 16:05:44
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;

int main(){
  int n,m;
  cin>>n>>m;
  int b[n];
  rep(i,n){
    cin>>b[i];
  }
  sort(b,b+n);
  int cnt=0;
  while(1){
    if(m<b[cnt]){
      cout<<cnt<<endl;
      return 0;
    }
    if(m==b[cnt]){
      cout<<cnt+1<<endl;
      return 0;
    }
    m-=b[cnt];
    cnt++;
    //cout<<cnt<<" "<<m<<endl;
  }
  return 0;
}
0