結果

問題 No.91 赤、緑、青の石
ユーザー masa
提出日時 2015-03-01 14:33:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 507 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 57,596 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-24 06:47:11
合計ジャッジ時間 1,486 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

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

	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