結果

問題 No.5 数字のブロック
ユーザー dgd1724
提出日時 2016-09-06 18:46:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 452 bytes
コンパイル時間 633 ms
コンパイル使用メモリ 67,232 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-15 20:37:08
合計ジャッジ時間 1,515 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>

int main(void) {

	//test用
	//std::ifstream in("test.txt");
	//std::cin.rdbuf(in.rdbuf());

	int L, N;
	std::cin >> L >> N;
	std::vector<int> W(N);

	for (int i = 0; i < N; i++) {
		std::cin >> W[i];
	}
	std::sort(W.begin(), W.end());

	int max = 0;
	int i = 0;
	while (max <= L && i < N) {
		max += W[i];
		i++;
	}

	std::cout << i - 1 << std::endl;

}
0