結果

問題 No.5 数字のブロック
ユーザー koyumeishi
提出日時 2015-01-07 23:40:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 479 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 77,748 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-17 22:16:09
合計ジャッジ時間 1,630 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <cmath>

using namespace std;


int main(){
	int L;
	cin >> L;
	int N;
	cin >> N;
	vector<int> W(N);
	for(int i=0; i<N; i++){
		cin >> W[i];
	}
	sort(W.begin(), W.end());
	int ans = 0;
	for(int i=0; i<N; i++){
		if(L-W[i]>=0){
			ans++;
			L-=W[i];
		}else{
			break;
		}
	}
	cout << ans << endl;
	return 0;
}
0