結果

問題 No.156 キャンディー・ボックス
ユーザー parsee1053
提出日時 2020-07-05 20:15:06
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 928 ms
コンパイル使用メモリ 77,788 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-22 20:26:08
合計ジャッジ時間 2,003 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

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