結果

問題 No.5 数字のブロック
ユーザー yanozawayanozawa
提出日時 2019-10-19 22:42:49
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 311 ms / 5,000 ms
コード長 535 bytes
コンパイル時間 946 ms
コンパイル使用メモリ 29,184 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 09:17:30
合計ジャッジ時間 4,816 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 119 ms
4,376 KB
testcase_04 AC 78 ms
4,380 KB
testcase_05 AC 196 ms
4,376 KB
testcase_06 AC 81 ms
4,376 KB
testcase_07 AC 56 ms
4,380 KB
testcase_08 AC 106 ms
4,376 KB
testcase_09 AC 13 ms
4,380 KB
testcase_10 AC 229 ms
4,380 KB
testcase_11 AC 53 ms
4,376 KB
testcase_12 AC 129 ms
4,380 KB
testcase_13 AC 188 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 205 ms
4,380 KB
testcase_17 AC 279 ms
4,380 KB
testcase_18 AC 244 ms
4,376 KB
testcase_19 AC 311 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 0 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 0 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 74 ms
4,380 KB
testcase_30 AC 18 ms
4,376 KB
testcase_31 AC 0 ms
4,380 KB
testcase_32 AC 0 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void) {
	int L, N;
	scanf("%d%d", &L, &N);
	int W[10000];
	int min = 10000;
	for (int i = 0; i < N; i++) {
		scanf("%d", &W[i]);
	}
	int a = 0;
	int sum = 0;
	int count = 0;
	
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 1 - i; j++) {
			if (W[j] > W[j + 1]) {
				a = W[j];
				W[j] = W[j + 1];
				W[j + 1] = a;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		if (sum + W[i] <= L) {
			sum += W[i];
			count++;
		}
	}
	printf("%d\n", count);
	

	return 0;

}
0