結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 WA -
testcase_03 AC 75 ms
4,380 KB
testcase_04 AC 14 ms
4,376 KB
testcase_05 AC 121 ms
4,376 KB
testcase_06 AC 52 ms
4,376 KB
testcase_07 AC 35 ms
4,380 KB
testcase_08 AC 64 ms
4,380 KB
testcase_09 AC 10 ms
4,384 KB
testcase_10 AC 121 ms
4,380 KB
testcase_11 AC 30 ms
4,376 KB
testcase_12 AC 82 ms
4,380 KB
testcase_13 AC 106 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 127 ms
4,376 KB
testcase_17 AC 177 ms
4,380 KB
testcase_18 AC 141 ms
4,376 KB
testcase_19 AC 196 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 0 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,384 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 14 ms
4,376 KB
testcase_30 AC 11 ms
4,380 KB
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 (1) {
		sum += a[count];
		count++;

		if (sum + a[count] > L) break;

	}

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

	return 0;
}
0