結果

問題 No.5 数字のブロック
コンテスト
ユーザー N/A
提出日時 2018-06-28 16:21:14
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 545 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 140 ms
コンパイル使用メモリ 39,236 KB
最終ジャッジ日時 2026-02-22 01:17:47
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 3 RE * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int width, freq, sw[256];
	int i, j, cnt = 0, smt = 10000;

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

	for (i = 0; i < freq; i++) {
		scanf("%d", &sw[i]);
	}

	while (1) {
		for (i = 0; i < freq; i++) {
			if (sw[i] < smt)
				smt = sw[i];
		}

			if (smt < width) {
				width -= smt;
				cnt++;
				for (i = 0; i < freq; i++) {
					if (sw[i] == smt) {
						sw[i] = 10000;
						smt = 10000;
					}
				}
			}
			else
				break;
		
	}

	printf("%d\n", cnt);

	return 0;
}
0