結果

問題 No.5 数字のブロック
ユーザー soupesuteaka
提出日時 2014-12-29 01:25:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 724 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 87,332 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-17 22:15:57
合計ジャッジ時間 1,391 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <iomanip>

#define INF 1000000001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const double PI = acos(-1.0);

int N, L;
int W[100001];

int main()
{
	ios::sync_with_stdio(false);

	cin >> L >> N;
	FOR(i,0,N) cin >> W[i];
	sort(W, W+N);
	int ans=0;
	FOR(i,0,N) {
		if (L-W[i]>=0) {
			ans++;
			L -= W[i];
		}
	}
	cout << ans << endl;

	return 0;
}
0