結果

問題 No.5 数字のブロック
ユーザー mosmos_21mosmos_21
提出日時 2016-01-19 20:02:56
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 176 ms / 5,000 ms
コード長 673 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 21,632 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 06:47:36
合計ジャッジ時間 2,634 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 67 ms
5,376 KB
testcase_04 AC 43 ms
5,376 KB
testcase_05 AC 109 ms
5,376 KB
testcase_06 AC 47 ms
5,376 KB
testcase_07 AC 35 ms
5,376 KB
testcase_08 AC 66 ms
5,376 KB
testcase_09 AC 8 ms
5,376 KB
testcase_10 AC 134 ms
5,376 KB
testcase_11 AC 31 ms
5,376 KB
testcase_12 AC 70 ms
5,376 KB
testcase_13 AC 106 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 0 ms
5,376 KB
testcase_16 AC 117 ms
5,376 KB
testcase_17 AC 158 ms
5,376 KB
testcase_18 AC 137 ms
5,376 KB
testcase_19 AC 176 ms
5,376 KB
testcase_20 AC 0 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 0 ms
5,376 KB
testcase_23 AC 0 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 0 ms
5,376 KB
testcase_27 AC 0 ms
5,376 KB
testcase_28 AC 0 ms
5,376 KB
testcase_29 AC 44 ms
5,376 KB
testcase_30 AC 10 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 0 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:11:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d %d", &box_width, &block_all);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:15:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |                 scanf("%d", &block[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~

ソースコード

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