結果

問題 No.5 数字のブロック
ユーザー pengin_2000
提出日時 2019-07-11 12:12:18
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 372 bytes
コンパイル時間 138 ms
コンパイル使用メモリ 28,416 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 11:54:31
合計ジャッジ時間 1,234 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
int asc(const void* a, const void* b)
{
	return *(int*)a - *(int*)b;
}
int main()
{
	int l, n;
	scanf("%d%d", &l, &n);
	int i;
	int w[10004];
	for (i = 0; i < n; i++)
		scanf("%d", &w[i]);
	qsort(w, n, sizeof(int), asc);
	int ans = 0;
	i = 0;
	while (l - w[i] >= 0)
	{
		ans++;
		l -= w[i];
		i++;
	}
	printf("%d\n", ans);
	return 0;
}
0