結果

問題 No.5 数字のブロック
ユーザー hanorver
提出日時 2015-09-07 20:37:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 405 bytes
コンパイル時間 938 ms
コンパイル使用メモリ 64,372 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 07:35:06
合計ジャッジ時間 1,776 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
	int box_width, toys;
	std::cin >> box_width >> toys;

	std::vector<int> v(toys);
	for (int i = 0; i < toys; i++) {
		std::cin >> v[i];
	}

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

	int count;
	for (count = 0; count < toys; count++) {
		if (box_width < v[count])break;
		box_width -= v[count];
	}
	std::cout << count << std::endl;
	return 0;
}
0