結果

問題 No.5 数字のブロック
ユーザー GreekFellows
提出日時 2016-05-07 00:53:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 451 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 64,708 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-05 10:13:28
合計ジャッジ時間 1,659 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
	int boxWidth, numBlocks;
	std::vector<int> blockWidths;

	std::cin >> boxWidth >> numBlocks;
	for (int i = 0; i < numBlocks; ++i) {
		int r;
		std::cin >> r;
		blockWidths.push_back(r);
	}

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

	int sum = 0;
	int count = 0;
	while (sum < boxWidth) {
		sum += blockWidths[count];
		++count;
	}

	std::cout << count;

	return 0;
}
0