結果

問題 No.156 キャンディー・ボックス
ユーザー komori3
提出日時 2017-08-25 17:36:47
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 364 bytes
コンパイル時間 473 ms
コンパイル使用メモリ 68,044 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 16:05:11
合計ジャッジ時間 1,274 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <functional>
using namespace std;

int main()
{
	int N, M, t;
	cin >> N >> M;
	priority_queue<int, vector<int>, greater<int> > pq;
	for (int i = 0; i < N; i++) 
		pq.push((cin >> t, t));
	
	while (!pq.empty()) {
		if (M < pq.top()) break;
		M -= pq.top();
		pq.pop();
	}

	cout << N - pq.size() << endl;
	
	return 0;
}
0