結果

問題 No.5 数字のブロック
ユーザー KUSAKA Gen
提出日時 2018-06-25 17:24:48
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 459 bytes
コンパイル時間 469 ms
コンパイル使用メモリ 55,420 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-30 22:39:28
合計ジャッジ時間 2,551 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int main()
{
	int L, N, sum = 0, count = 0;
	int W[10000];
	
	cin >> L >> N;
	for(int i = 0; i < N; ++i)
	{
		cin >> W[i];
	}
	
	for(int i = 0; i < N - 1; ++i)
	{
		for(int j = N - 1; j > i; --j)
		{
			if(W[j - 1] > W[j])
			{
				int temp = W[j - 1];
				W[j - 1] = W[j];
				W[j] = temp;
			}
		}
	}
	
	for(int i = 0; sum + W[i] <= L; ++i)
	{
		sum += W[i];
		count++;
	}
	
	cout << count << endl;
	
	
	return 0;
}
0