結果

問題 No.5 数字のブロック
ユーザー machibito2machibito2
提出日時 2016-05-08 17:05:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 433 bytes
コンパイル時間 861 ms
コンパイル使用メモリ 76,436 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 08:34:15
合計ジャッジ時間 1,884 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
	priority_queue<int, vector<int>, greater<int> > minpq;
	int L,N;
	int a;
	cin >> L >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a;
		minpq.push(a);
	}
	int ans = 0,ima;
	for (int i = 0; i < N; i++)
	{
		int ima = minpq.top();
		minpq.pop();
		L -= ima;
		if(L < 0)
		{
			break;
		}
		++ans;
	}
	cout << ans << endl;
}
0