結果
| 問題 | 
                            No.91 赤、緑、青の石
                             | 
                    
| コンテスト | |
| ユーザー | 
                             lapi
                         | 
                    
| 提出日時 | 2019-03-31 20:44:29 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 5,000 ms | 
| コード長 | 1,178 bytes | 
| コンパイル時間 | 1,297 ms | 
| コンパイル使用メモリ | 105,164 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-24 07:18:20 | 
| 合計ジャッジ時間 | 2,255 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 28 | 
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
// n個作れるかどうか
bool canMake(int a, int b, int c, int n) {
	int res = 0;
	if (c >= n) res += (c - n) / 2;
	else res -= (n - c);
	if (b >= n) res += (b - n) / 2;
	else res -= (n - b);
	if (a >= n) res += (a - n) / 2;
	else res -= (n - a);
	return (res >= 0);
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int num[3];
	cin >> num[0] >> num[1] >> num[2];
	sort(num, num + 3);
	
	int ans = num[0];
	num[2] -= num[0];
	num[1] -= num[0];
	num[0] = 0;
	// left <= 解 < right
	int left = 0;
	int right = num[2] + 1;
	
	while (left + 1 != right) {
		int mid = (left + right)/2;
		if (canMake(num[0],num[1],num[2],mid)) left = mid;
		else right = mid;
	}
	ans += left;
	cout << ans << endl;
	// cout << canMake(num[0], num[1], num[2], 10) << endl;
	return 0;
}
            
            
            
        
            
lapi