結果

問題 No.5 数字のブロック
ユーザー TaK7907
提出日時 2017-10-13 06:09:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 56 ms / 5,000 ms
コード長 537 bytes
コンパイル時間 943 ms
コンパイル使用メモリ 78,740 KB
最終ジャッジ日時 2025-01-05 03:13:19
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	double BoxWidth;
	int NumberOfBlocks;
	vector<double> BlockWidths;
	cin >> BoxWidth >> NumberOfBlocks;
	for (auto i = 0; i != NumberOfBlocks; ++i) {
		double w;
		cin >> w;
		BlockWidths.push_back(w);
	}
	sort(BlockWidths.begin(), BlockWidths.end());
	double BockWidthAmount(0);
	int i(0);
	for (; i != NumberOfBlocks; ++i) {
		BockWidthAmount += BlockWidths.at(i);
		if (BockWidthAmount > BoxWidth) break;
	}
	cout << i << endl;
	return 0;
}
0