結果

問題 No.91 赤、緑、青の石
コンテスト
ユーザー masa
提出日時 2015-03-01 14:33:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0 + boost 1.89.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 507 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 374 ms
コンパイル使用メモリ 62,600 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-12-07 12:21:08
合計ジャッジ時間 1,487 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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);
	}

	while (x >= 3 && y > 0) {
		if (x >= 3) {
			x -= 3;
			y--;
			ans++;
		}

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

	ans += x / 5;

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