結果

問題 No.5 数字のブロック
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-06 22:55:02
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 198 ms / 5,000 ms
コード長 514 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 20,864 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 01:02:57
合計ジャッジ時間 2,445 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 76 ms
5,376 KB
testcase_04 AC 20 ms
5,376 KB
testcase_05 AC 124 ms
5,376 KB
testcase_06 AC 52 ms
5,376 KB
testcase_07 AC 35 ms
5,376 KB
testcase_08 AC 64 ms
5,376 KB
testcase_09 AC 9 ms
5,376 KB
testcase_10 AC 125 ms
5,376 KB
testcase_11 AC 31 ms
5,376 KB
testcase_12 AC 83 ms
5,376 KB
testcase_13 AC 110 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 128 ms
5,376 KB
testcase_17 AC 177 ms
5,376 KB
testcase_18 AC 144 ms
5,376 KB
testcase_19 AC 198 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 1 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 20 ms
5,376 KB
testcase_30 AC 11 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 0 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:23:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |         scanf("%d", &L);
      |         ^~~~~~~~~~~~~~~
main.c:24:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |         scanf("%d", &N);
      |         ^~~~~~~~~~~~~~~
main.c:27:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |                 scanf("%d", &W[i]);
      |                 ^~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

void bubble(int len, int *W){
	int i,j;
	for(i=0;i<len;i++){
		for(j=i+1;j<len;j++){
			if( W[i] > W[j] ){
				int tmp = W[i];
				W[i] = W[j];
				W[j] = tmp;
			}
		}
	}
}

int main(void){
	int i;
	int L, N;
	int W[10100];
	
	int sum = 0;
	int count = 0;
	scanf("%d", &L);
	scanf("%d", &N);
	
	for(i=0;i<N;i++){
		scanf("%d", &W[i]);
	}
	
	bubble(N, W);
	
	for(i=0;i<N;i++){
		if( (sum+W[i]) > L ){
			break;
		}else{
			count++;
			sum += W[i];
		}
	}
	
		printf("%d\n", count);
	return 0;
}
0