結果

問題 No.5 数字のブロック
ユーザー Klay
提出日時 2017-04-21 20:47:50
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 478 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 56,124 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-20 05:12:37
合計ジャッジ時間 2,322 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

int main(void)
{
	int N, L;
	std::cin >> L >> N;
	
	int a[N];
	
	for(int i = 0; i < N; i ++)
	{
		std::cin >> a[i];
	}
	
	for(int i = 0; i < N; i ++)
	{
		for(int j = N - 1; j > i; j --)
		{
			if(a[j] < a[j - 1])
			{
				int buff = a[j];
				a[j] = a[j - 1];
				a[j - 1] = buff;
			}
		}
	}
	
	int sum = 0;
	int count = 0;
	
	do
	{
		sum += a[count];
		count ++;
	}
	while(sum < L);
	
	if(sum > L)
	{
		count --;
	}
	
	std::cout << count << std::endl;
}
0