結果

問題 No.5 数字のブロック
ユーザー hayakawa4739hayakawa4739
提出日時 2016-06-28 01:34:01
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 620 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 03:37:08
合計ジャッジ時間 2,178 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 72 ms
5,376 KB
testcase_04 AC 19 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 48 ms
5,376 KB
testcase_07 AC 34 ms
5,376 KB
testcase_08 AC 57 ms
5,376 KB
testcase_09 AC 8 ms
5,376 KB
testcase_10 AC 116 ms
5,376 KB
testcase_11 AC 27 ms
5,376 KB
testcase_12 AC 75 ms
5,376 KB
testcase_13 AC 98 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 114 ms
5,376 KB
testcase_17 AC 160 ms
5,376 KB
testcase_18 AC 136 ms
5,376 KB
testcase_19 AC 182 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 WA -
testcase_22 WA -
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 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 0 ms
5,376 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 0 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d", &width);
      |         ^~~~~~~~~~~~~~~~~~~
main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%d", &number);
      |         ^~~~~~~~~~~~~~~~~~~~
main.c:14:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |                 scanf("%d", &haba[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

int main(void) {
	int width, number, tmp, count;

	count = 0;

	scanf("%d", &width);
	scanf("%d", &number);

	int haba[number];

	for (int i = 0; i < number; i++) {
		scanf("%d", &haba[i]);
	}

	//数値を昇順にソート
	for (int i = 0; i < number; ++i) {
		for (int j = i + 1; j < number; ++j) {
			if (haba[i] > haba[j]) {
				tmp = haba[i];
				haba[i] = haba[j];
				haba[j] = tmp;
			}
		}
	}

	for (int i = 0; i < number; i++) {
		if (width >= 0) {
			width = width - haba[i];
			if (width <= 0) {
				break;
			}else{
				count++;
			}
		} else {
			break;
		}
	}

	printf("%d", count);

}
0