結果

問題 No.5 数字のブロック
ユーザー open_nurumy
提出日時 2015-08-17 04:47:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 381 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 69,008 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 07:30:41
合計ジャッジ時間 1,768 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

int main()
{
	int l, n, count = 0;

	cin>>l>>n;

	vector<int> w;

	for(int i = 0; i<n; i++) {
		int x;
		cin>>x;
		w.push_back(x);
	}

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

	for(int j = 0; j<n; j++) {
		if(l>=w[j]) {
			l = l - w[j];
			count++;
		}
	}

	cout<<count<<endl;

	return 0;
}
0