結果

問題 No.5 数字のブロック
ユーザー monburan_0401monburan_0401
提出日時 2018-08-27 23:21:09
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 339 ms / 5,000 ms
コード長 748 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 30,208 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 09:58:37
合計ジャッジ時間 3,659 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 123 ms
5,376 KB
testcase_04 AC 78 ms
5,376 KB
testcase_05 AC 206 ms
5,376 KB
testcase_06 AC 83 ms
5,376 KB
testcase_07 AC 60 ms
5,376 KB
testcase_08 AC 109 ms
5,376 KB
testcase_09 AC 13 ms
5,376 KB
testcase_10 AC 247 ms
5,376 KB
testcase_11 AC 53 ms
5,376 KB
testcase_12 AC 139 ms
5,376 KB
testcase_13 AC 199 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 219 ms
5,376 KB
testcase_17 AC 303 ms
5,376 KB
testcase_18 AC 262 ms
5,376 KB
testcase_19 AC 339 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 76 ms
5,376 KB
testcase_30 AC 18 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*	数字が書かれているブロックはそれぞれ高さ1で幅は𝑊𝑖 である。
それらのブロックを高さ1,幅Lの箱の中に入れる。
最大でいくつ入るか。 */
#include <stdio.h>
int main(void){
	int L,N;		//	入力値
	int W[10000];
	int i,j;
	int wn;
	int count = 0;
	
	scanf("%d%d",&L,&N);
	for (i = 0; i < N; i++){
		scanf("%d",&wn);
		W[i] = wn;
	}
	
	//	小さい順に並べる
	for (i = 0; i < N - 1; i++){
		for (j = 0; j < N - 1; j++){
			if (W[j] > W[j + 1]){
				wn = W[j];
				W[j] = W[j + 1];
				W[j + 1] = wn;
			}
		}
	}
	
	//	順番にLから引く
	i = 0;
	while (L > 0 && i < N){
		L -= W[i];
		count += 1;
		i += 1;
	}	
	if (L < 0){
		count -= 1;
	}
	
	printf("%d\n",count);
	
	return 0;
}
0