結果

問題 No.5 数字のブロック
ユーザー jajagacchi
提出日時 2016-12-30 23:31:25
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 351 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 63,500 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-21 09:43:31
合計ジャッジ時間 1,830 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>

int main()
{
	int L; std::cin >> L;
	int N; std::cin >> N;
	std::priority_queue<int, std::vector<int>, std::greater<int> > pq;
	int tmp;
	while(std::cin >> tmp)
	{
		pq.push(tmp);
	}

	int sum = 0 , n = 0;
	while(sum <= L)
	{
		sum += pq.top(); pq.pop();
		n++;
	}
	n--;
	std::cout << n << std::endl;
	return 0;
}
0