結果

問題 No.5 数字のブロック
ユーザー mosmos_21mosmos_21
提出日時 2016-01-19 20:02:56
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 182 ms / 5,000 ms
コード長 673 bytes
コンパイル時間 531 ms
コンパイル使用メモリ 24,724 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-11 14:32:07
合計ジャッジ時間 3,199 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,356 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 73 ms
4,376 KB
testcase_04 AC 48 ms
4,380 KB
testcase_05 AC 121 ms
4,380 KB
testcase_06 AC 51 ms
4,380 KB
testcase_07 AC 33 ms
4,376 KB
testcase_08 AC 63 ms
4,376 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 138 ms
4,376 KB
testcase_11 AC 34 ms
4,380 KB
testcase_12 AC 80 ms
4,380 KB
testcase_13 AC 115 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 123 ms
4,380 KB
testcase_17 AC 172 ms
4,376 KB
testcase_18 AC 148 ms
4,376 KB
testcase_19 AC 182 ms
4,380 KB
testcase_20 AC 0 ms
4,380 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,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 0 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 47 ms
4,376 KB
testcase_30 AC 11 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 0 ms
4,384 KB
testcase_33 AC 0 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int main(void) {
	
	int box_width;
	int block_all;
	int count = 0;
	int i, j, tmp;
	
	scanf("%d %d", &box_width, &block_all);
	
	int block[block_all];
	for(i = 0; i< block_all; i++)
		scanf("%d", &block[i]);
	
	//sort
	for (i = 0; i < block_all - 1; i++){
        for (j = block_all - 1; j > i; j--){
            if (block[j - 1] > block[j]){
                tmp = block[j];
                block[j] = block[j - 1];
                block[j - 1]= tmp;
            }
        }
	}
	
	int sum = 0;
	for(count = 0; count < block_all; count++){
		sum += block[count];
		if(sum > box_width) break;
	}
	
	printf("%d\n", count);

	return 0;
}
0