結果

問題 No.5 数字のブロック
ユーザー shisyamokongari
提出日時 2016-08-22 00:32:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 270 bytes
コンパイル時間 711 ms
コンパイル使用メモリ 59,388 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-18 08:53:55
合計ジャッジ時間 1,321 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>

using namespace std;

#define NMAX 10000

int main(){

	int L,N,W[NMAX];

	cin>>L;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>W[i];
	}

	sort(W,W+N);

	int k;
	for(k=0;k<N;k++){
		if(L-W[k]<0) break;
		L-=W[k];
	}

	cout<<k<<endl;
}

0