結果

問題 No.5 数字のブロック
ユーザー arutemyan
提出日時 2016-10-29 19:53:39
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 461 bytes
コンパイル時間 610 ms
コンパイル使用メモリ 65,028 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 18:23:04
合計ジャッジ時間 1,707 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
#include <algorithm>

int main(int, char **)
{
	int l;
	size_t n;
	std::vector<int> w;
	w.reserve(10000);
	std::cin >> l >> n;
	for (int i = 0, input = 0; i < n; ++i)
	{
		std::cin >> input;
		w.push_back(input);
	}

	if (n != w.size())
	{
		return -1;
	}

	std::sort(w.begin(), w.end());

	int cnt = 0;
	for (int i = 0, s = 0; i < l && (s += w[i]) <= l; ++i)
	{
		++cnt; 
	}

	std::cout << cnt << std::endl;

	return 0;
}
0