結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
![]() |
提出日時 | 2016-02-14 14:54:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 511 bytes |
コンパイル時間 | 967 ms |
コンパイル使用メモリ | 63,796 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 15:47:08 |
合計ジャッジ時間 | 1,554 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream> #include <queue> #include <vector> using namespace std; int main() { int n, m, ans = 0; priority_queue<int,vector<int>,greater<int>> cs; cin >> n >> m; for (int i = 0; i < n; i++) { int c; cin >> c; cs.push(c); } while (m > 0 && !cs.empty()) { int c = cs.top(); if (c <= m) { m -= c; ans++; cs.pop(); } else break; } cout << ans << endl; return 0; }