結果

問題 No.5 数字のブロック
ユーザー agis
提出日時 2017-03-27 20:57:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 389 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 60,348 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 12:19:56
合計ジャッジ時間 1,569 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
	int L,N;
	int W[10000];
	cin >> L;
	cin >> N;
	for (int i = 0;i <= N-1;i++) {
		cin >> W[i];
	}
	sort(W, W + N);
	int l = 0;	
	int j = 0;	//count
	while (j != N) {
		 l = l + W[j];
		if (l > L) {
			cout << j << endl;
			break;
		}else if (l <= L) {
			cout << j + 1 << endl;
			break;
		}
		j++;
	}
	
	return 0;
}
0