結果

問題 No.5 数字のブロック
ユーザー potato607potato607
提出日時 2020-06-30 01:06:34
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 190 ms / 5,000 ms
コード長 587 bytes
コンパイル時間 708 ms
コンパイル使用メモリ 28,832 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 11:31:02
合計ジャッジ時間 3,067 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 73 ms
4,376 KB
testcase_04 AC 13 ms
4,380 KB
testcase_05 AC 119 ms
4,380 KB
testcase_06 AC 51 ms
4,384 KB
testcase_07 AC 34 ms
4,380 KB
testcase_08 AC 60 ms
4,380 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 116 ms
4,376 KB
testcase_11 AC 29 ms
4,376 KB
testcase_12 AC 80 ms
4,380 KB
testcase_13 AC 103 ms
4,376 KB
testcase_14 AC 0 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 122 ms
4,380 KB
testcase_17 AC 172 ms
4,380 KB
testcase_18 AC 137 ms
4,376 KB
testcase_19 AC 190 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 0 ms
4,376 KB
testcase_23 AC 0 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 13 ms
4,380 KB
testcase_30 AC 10 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,384 KB
testcase_33 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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);

	if (a[0] <= L) {
		while (1) {
			sum += a[count];
			count++;

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

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

	return 0;
}
0