結果

問題 No.5 数字のブロック
ユーザー ひゅーらひゅーら
提出日時 2017-06-21 17:04:46
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 515 bytes
コンパイル時間 1,296 ms
コンパイル使用メモリ 30,592 KB
実行使用メモリ 8,480 KB
最終ジャッジ日時 2024-04-10 09:07:21
合計ジャッジ時間 6,760 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
int main(void){
	int l, n;
	scanf("%d%d", &l, &n);
	int w[10005];
	for(int i = 0; i < n; i++){
		scanf("%d", w+i);
	}
	int flag;
	while(!(flag)){
		flag = 0;
		for(int i = 0; i < n-1; i++){
			if(w[i] > w[i+1]){
				int temp = w[i];
				w[i] = w[i+1];
				w[i+1] = temp;
				flag++;
			}
		}
	}
#ifdef DEBUG
for(int i = 0; i < n; i++){
printf("w[%d] %d\n", i, w[i]);
}
#endif
	int sum;
	for(int i = 0; i < n; i++){
		sum += w[i];
		if(sum > l){
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}
0