結果

問題 No.5 数字のブロック
ユーザー albicilla
提出日時 2016-04-05 14:36:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 347 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 59,228 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-04 01:19:01
合計ジャッジ時間 2,743 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 WA * 9 RE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;


int l,n;
int w[1010];

int main(){
	cin>>l>>n;
	for(int i=0;i<n;i++){
		cin>>w[i];
	}
	sort(w,w+n);

	//for(int j=0;j<n;j++)cout<<"w["<<j<<"]="<<w[j]<<endl;
	
	int total =0;
	int ans=0;
	for(int i=0;i<n;i++){

		total+=w[i];
		
		if(total>l)break;
		
		ans++;
	}

	cout<<ans<<endl;
}
0