結果

問題 No.91 赤、緑、青の石
ユーザー nak3
提出日時 2017-03-12 19:17:33
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 821 bytes
コンパイル時間 1,368 ms
コンパイル使用メモリ 159,704 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-24 07:04:22
合計ジャッジ時間 2,429 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a+3);
	int ret = 0;
	int m = a[0];
	ret += m;
	for (int i = 0; i < 3; i++) {
		a[i]-=m;
	}

	while (true) {
//		cout << a[0] << " " << a[1] << " " << a[2] << "\n";
		if (a[2]>=3&&a[1]>0) {
			ret++;
			a[2]-=3;
			a[1]-=1;
			if (a[1]>a[2]) {
				int tmp = a[2];
				a[2] = a[1];
				a[1] = tmp;
			}
		}
		else if (a[1]>=3&&a[2]>0) {
			ret++;
			a[1]-=3;
			a[2]-=1;
		}
		else if (a[2]>=5) {
			ret++;
			a[2]-=5;
			if (a[1]>a[2]) {
				int tmp = a[2];
				a[2] = a[1];
				a[1] = tmp;
			}
		}
		else if (a[1]>=5) {
			ret++;
			a[1]-=5;
		} else {
			break;
		}
	}
	cout << ret << endl;
}
0