結果

問題 No.5 数字のブロック
ユーザー ミドリムシ
提出日時 2017-10-14 15:44:11
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 314 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 60,348 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-18 11:47:36
合計ジャッジ時間 1,382 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
	int L, N;
	cin >> L >> N;
	int W[N];
	for(int i = 0; i < N; i++){
		cin >> W[i];
	}
	sort(W, W + N);
	int all = 0;
	for(int i = 0; i < N; i++){
		all += W[i];
		if(all > L){
			cout << i << endl;
			return 0;
		}
	}
	cout << N << endl;
}
0