結果

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

ソースコード

diff #

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

using namespace std;

int main()
{
	int L, N;
	cin >> L;
	cin >> N;

	vector<int> W;

	int temp;
	for (int i = 0; i < N; i++){
		cin >> temp;
		W.push_back(temp);
	}

	sort(W.begin(), W.end());

	int count = 0;
	for (vector<int>::size_type i = 0; i < W.size(); i++){
		if (L > 0){
			L -= W[i];
			count++;
		}
		else
			break;
	}
	cout << count << endl;
}
0