結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
👑 |
提出日時 | 2020-01-07 23:16:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 447 bytes |
コンパイル時間 | 683 ms |
コンパイル使用メモリ | 74,416 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-23 01:20:50 |
合計ジャッジ時間 | 4,439 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 RE * 1 |
other | AC * 5 WA * 7 RE * 18 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n,m;cin>>n>>m; vector<int> a(n); for(int i = 0; n > i; i++){ cin>>a[i]; } int ans = 0; sort(a.begin(),a.end()); for(int i = 0; 1; i++){ if(m >= a[i]){ ans++; a[i] = 0; m -= a[i]; }else{ cout << ans << endl; return 0; } } }