結果

問題 No.91 赤、緑、青の石
コンテスト
ユーザー HiroakiSoftware
提出日時 2014-12-07 23:11:44
言語 C++11
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 17 ms / 5,000 ms
+ 542µs
コード長 844 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 91 ms
コンパイル使用メモリ 38,912 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-19 04:08:34
合計ジャッジ時間 1,952 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/*
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