結果

問題 No.5 数字のブロック
ユーザー 一ノ瀬卯月
提出日時 2019-02-18 13:51:51
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 367 bytes
コンパイル時間 881 ms
コンパイル使用メモリ 65,524 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-18 12:56:13
合計ジャッジ時間 1,859 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;
int main()
{
	vector<int> arr;
	int a, b, c=0;
	cin >> a >> b;
	arr.resize(b);
	while (b>0)
	{
		cin >> arr[b-1];
		b--;
	}

	sort(arr.begin(), arr.end());
	for (unsigned int i = 0; i < arr.size(); i++)
	{
		a -= arr[i];
		if (a < 0) break;
		c++;
	}

	cout << c << endl;

	return 0;
}
0