結果

問題 No.91 赤、緑、青の石
コンテスト
ユーザー めうめう🎒
提出日時 2016-03-30 09:49:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0 + boost 1.89.0)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 717 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 578 ms
コンパイル使用メモリ 84,368 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-12-07 12:25:39
合計ジャッジ時間 1,923 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	int r,g,b,ans = 0;
	cin >> r >> g >> b;
	int m;
	while(true){

		m = min(r,min(g,b));
		ans += m;
		r -= m,g -= m,b -= m;

		if(g <= r && b <= r){
			if(r > 2) r-= 2;
			else break;
		}else if(r <= g && b <= g){
			if(g > 2) g -= 2;
			else break;
		}else{
			if(b > 2) b -= 2;
			else break;
		}

		if(r == 0){
			r += 1;
		}else if(g == 0){
			g += 1;
		}else{
			b += 1;
		}
	}
	cout << ans << endl;
	return 0;
}
0