結果
問題 | No.156 キャンディー・ボックス |
ユーザー | nabla_delta |
提出日時 | 2019-09-30 01:48:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 399 bytes |
コンパイル時間 | 1,913 ms |
コンパイル使用メモリ | 168,908 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-03 04:47:51 |
合計ジャッジ時間 | 2,516 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; int main(){ int n, m; cin >> n >> m; int c[n]; for(int i=0; i<n; i++) cin >> c[i]; sort(c, c+n); for(int i=0; i<n; i++){ if(m>=c[i]){ m-=c[i]; c[i]=0; }else{ c[i]-=m; m=0; } } int ans=0; for(int i=0; i<n; i++){ if(c[i]==0) ans++; } cout << ans << endl; return 0; }