結果

問題 No.91 赤、緑、青の石
ユーザー hotpepsihotpepsi
提出日時 2014-12-07 22:49:35
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 665 bytes
コンパイル時間 654 ms
コンパイル使用メモリ 67,380 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-24 06:45:12
合計ジャッジ時間 1,654 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cmath>

using namespace std;

int solve(int r, int g, int b)
{
	int ans = min(r, min(g, b));
	int a[3] = { r - ans, g - ans, b - ans };
	sort(a, a + 3);
	a[0] = a[1], a[1] = a[2];
	while (a[0] >= 1 && a[1] >= 3) {
		++ans;
		a[0] -= 1, a[1] -= 3;
		if (a[1] < a[0]) {
			swap(a[0], a[1]);
		}
	}
	ans += a[1] / 5;
	return ans;
}

int main(int argc, char *argv[])
{
	string s;
	int r, g, b;
	while (getline(cin, s) && !s.empty()) {
		stringstream ss(s);
		ss >> r >> g >> b;
//		cout << r << "," << g << "," << b << endl;
		cout << solve(r, g, b) << endl;
	}
}
0