結果

問題 No.91 赤、緑、青の石
ユーザー masa
提出日時 2015-02-28 19:51:05
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 507 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 57,432 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-24 00:27:44
合計ジャッジ時間 1,924 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
	int r, g, b;

	cin >> r >> g >> b;
	int made = min({r, g, b});
	int ans = 0;

	r -= made;
	g -= made;
	b -= made;
	ans += made;

	int x, y;
	if (r == 0) {
		x = g;
		y = b;
	} else {
		x = r;
		y = max(g, b);
	}

	if (x < y) {
		swap(x, y);
	}

	do {
		made = min(x / 3, y);
		x -= 3 * made;
		y -= made;
		ans += made;

		if (x < y) {
			swap(x, y);
		}
	} while (made > 0);

	cout << ans << endl;
	return 0;
}
0