結果

問題 No.91 赤、緑、青の石
ユーザー HiroakiSoftwareHiroakiSoftware
提出日時 2014-12-07 23:11:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 844 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 25,816 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 12:08:23
合計ジャッジ時間 1,656 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
4,380 KB
testcase_01 AC 12 ms
4,376 KB
testcase_02 AC 11 ms
4,380 KB
testcase_03 AC 14 ms
4,376 KB
testcase_04 AC 11 ms
4,380 KB
testcase_05 AC 15 ms
4,376 KB
testcase_06 AC 7 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 16 ms
4,380 KB
testcase_13 AC 16 ms
4,376 KB
testcase_14 AC 13 ms
4,380 KB
testcase_15 AC 17 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 27 ms
4,380 KB
testcase_26 AC 22 ms
4,376 KB
testcase_27 AC 9 ms
4,384 KB
testcase_28 AC 8 ms
4,380 KB
testcase_29 AC 7 ms
4,384 KB
testcase_30 AC 15 ms
4,380 KB
testcase_31 AC 20 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
yukicoder No.91 赤、緑、青の石
解答者:ヒロソフ
*/
#include <stdio.h>

int main(void) {

	unsigned int r, g, b;
	unsigned int *p[2];
	int Count = 0;
	scanf("%u %u %u", &r, &g, &b);
	bool  bNext = false;
	do {
		bNext = false;
		while ((r > 0) && (g > 0) && (b > 0)) {
			//作れる間繰り返す
			Count++;
			r--;
			g--;
			b--;
		}
		//0のものを確認
		p[0] = nullptr;
		if (r == 0) p[0] = &r;
		else if (g == 0) p[0] = &g;
		else if (b == 0) p[0] = &b;

		//3つ以上あるもので最大のものを確認
		p[1] = &r;
		if (*p[1] < g) p[1] = &g;
		if (*p[1] < b) p[1] = &b;
		if (*p[1] >= 3) {
			//交換条件がそろったので交換して次のループへ
			*p[1] -= 2;
			*p[0] += 1;
			bNext = true;
		}
	} while (bNext);

	printf("%d\n", Count);
	return 0;
}
0