結果

問題 No.5 数字のブロック
ユーザー studypurogurastudypurogura
提出日時 2016-03-18 19:51:54
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 144 ms / 5,000 ms
コード長 746 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 24,888 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-11 14:47:51
合計ジャッジ時間 2,566 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 48 ms
4,376 KB
testcase_04 AC 29 ms
4,380 KB
testcase_05 AC 85 ms
4,380 KB
testcase_06 AC 30 ms
4,384 KB
testcase_07 AC 20 ms
4,376 KB
testcase_08 AC 42 ms
4,380 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 103 ms
4,380 KB
testcase_11 AC 18 ms
4,380 KB
testcase_12 AC 52 ms
4,380 KB
testcase_13 AC 82 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 89 ms
4,376 KB
testcase_17 AC 128 ms
4,384 KB
testcase_18 AC 112 ms
4,380 KB
testcase_19 AC 144 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 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,384 KB
testcase_27 AC 0 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 28 ms
4,380 KB
testcase_30 AC 6 ms
4,376 KB
testcase_31 AC 0 ms
4,376 KB
testcase_32 AC 0 ms
4,376 KB
testcase_33 AC 0 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#define NUM_BLOCK 10000

int bubblesort();

int main(){
	int wd_box,num_block;
	int wd_block[NUM_BLOCK]={0};
	int sum_wd=0;
	int i;
	
	scanf("%d",&wd_box);
	scanf("%d",&num_block);
	for(i=0; i<num_block;i=i+1){
	scanf("%d",&wd_block[i]);
	}
	
	bubblesort(wd_block,num_block);
	
	for(i=0;i<num_block;i++){
	sum_wd += wd_block[i];
		if(sum_wd>wd_box){
			printf("%d\n",i);
			return 0;
		}
	}
	if(sum_wd<=wd_box){
		printf("%d\n",num_block);
	}
	
	return 0;
}

int bubblesort(int wd_block[NUM_BLOCK],int num_block){
	int i,j,baff;
	for(i=0;i<num_block-1;i++){
		for(j=0;j<num_block-1-i;j++){
			if(wd_block[j]>wd_block[j+1]){
			baff = wd_block[j];
			wd_block[j] = wd_block[j+1];
			wd_block[j+1] = baff;
			}
		}
	}
	return 0;
}
0