結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 77 ms
5,376 KB
testcase_04 AC 20 ms
5,376 KB
testcase_05 AC 116 ms
5,376 KB
testcase_06 AC 49 ms
5,376 KB
testcase_07 AC 32 ms
5,376 KB
testcase_08 AC 60 ms
5,376 KB
testcase_09 AC 8 ms
5,376 KB
testcase_10 AC 118 ms
5,376 KB
testcase_11 AC 29 ms
5,376 KB
testcase_12 AC 80 ms
5,376 KB
testcase_13 AC 100 ms
5,376 KB
testcase_14 AC 0 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 118 ms
5,376 KB
testcase_17 AC 165 ms
5,376 KB
testcase_18 AC 134 ms
5,376 KB
testcase_19 AC 186 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 0 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 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 18 ms
5,376 KB
testcase_30 AC 10 ms
5,376 KB
testcase_31 AC 0 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:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%d", &width);
      |         ^~~~~~~~~~~~~~~~~~~
main.c:10:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%d", &number);
      |         ^~~~~~~~~~~~~~~~~~~~
main.c:15:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |                 scanf("%d", &haba[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

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

	goukei = 0;
	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 >= goukei) {
			goukei = goukei + haba[i];
			if (width >= goukei) {
				count++;
			}
		}
	}

	printf("%d", count);

}
0