結果

問題 No.5 数字のブロック
ユーザー potato607potato607
提出日時 2020-06-30 00:55:24
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 518 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 28,420 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 11:29:53
合計ジャッジ時間 3,279 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 80 ms
4,376 KB
testcase_04 AC 20 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 53 ms
4,376 KB
testcase_07 AC 35 ms
4,380 KB
testcase_08 AC 64 ms
4,376 KB
testcase_09 AC 9 ms
4,376 KB
testcase_10 AC 128 ms
4,380 KB
testcase_11 AC 31 ms
4,376 KB
testcase_12 AC 82 ms
4,376 KB
testcase_13 AC 109 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 WA -
testcase_16 AC 128 ms
4,376 KB
testcase_17 AC 179 ms
4,376 KB
testcase_18 AC 145 ms
4,384 KB
testcase_19 AC 197 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 0 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

void sort(int* a, int len) {

	int i, j;
	int temp = 0;

	for (i = 0;i < len;i++) {
		for (j = i + 1;j < len;j++) {
			if (a[i] > a[j]) {
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
		}
	}

	return;
}

int main(void) {
	
	int L, N;
	int a[10000];
	int i, sum,count;

	sum = 0;
	count = 0;

	scanf("%d", &L);
	scanf("%d", &N);

	for (i = 0;i < N;i++) scanf("%d", &a[i]);

	sort(a, N);

	while (sum < L - a[count]) {
		sum += a[count];
		count++;
	}

	printf("%d\n", count);

	return 0;
}
0