結果

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int med3(int a,int b,int c);
void Swap(int *x,int *y);

int main(){
	int R,G,B;
	cin>>R>>G>>B;


	int count=0;

	count = min(min(R,G),B);
	R-= count;
	G-= count;
	B-= count;
	int Maximum = max(max(R,G),B);
	int med = med3(R,G,B);

	if(med  == 0)
		count = count + (Maximum / 5);
	else {
		while (Maximum > 2){
			if (med == 0){
				count += Maximum / 5 ;
				break;
			}

			Maximum -= 3;
			med -= 1;
			if (Maximum < med)
				Swap(&Maximum,&med);

			count++;
		}

	}



	cout<<count<<endl;

	return 0;
}

int med3(int a,int b,int c){
	if (a >= b)
		if (b >= c)
			return b;
		else if (a <= c)
			return a;
		else 
			return c;
	else if (a > c)
		return a;
	else if (b > c)
		return c;
	else {
		return b;
	}
}

void Swap(int *x, int *y){
	int work;
	work = *x;
	*x = *y;
	*y = work;
}
0