結果

問題 No.91 赤、緑、青の石
ユーザー Naoyk1212Naoyk1212
提出日時 2017-06-06 19:06:15
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,104 bytes
コンパイル時間 1,176 ms
コンパイル使用メモリ 89,624 KB
実行使用メモリ 7,680 KB
最終ジャッジ日時 2023-10-23 17:59:49
合計ジャッジ時間 14,315 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <cmath>
#include <ccomplex>
using namespace std;

int sum(vector<int> v) {
	int sum = 0;
	for (int i = 0; i < 3; i++) {
		sum += v[i];
	}
	return sum;
}

bool check(vector<int> v) {
	bool ok = true;
	for (int i = 0; i < 3; i++) {
		if (v[i] < 0)ok = false;
	}
	return ok;
}
int main() {
	vector<int> color(3);
	for (int i = 0; i < 3; i++)cin >> color[i];

	int mn = *min_element(color.begin(), color.end());
	for (int i = 0; i < 3; i++)color[i] -= mn;
	int cnt = mn;
	sort(color.begin(), color.end());
	
	bool ok = true;
	while (ok) {
		if (sum(color) <= 2) {
			ok = false;
			break;
		}
		
		color[2] -= 2;
		color[0] += 1;
		ok = check(color);

		int mn = *min_element(color.begin(), color.end());
		if (mn >= 1) {
			cnt += mn;
			for (int i = 0; i < 3; i++)color[i] -= mn;
		}
		sort(color.begin(), color.end());
		cerr << color[0] << " " << color[1] << " " << color[2] << " " << cnt << endl;
	}
	cout << cnt << endl;
}
0