結果
| 問題 | No.91 赤、緑、青の石 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-09 15:19:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 740 bytes |
| 記録 | |
| コンパイル時間 | 1,110 ms |
| コンパイル使用メモリ | 158,236 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-07 12:28:31 |
| 合計ジャッジ時間 | 2,097 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,first,last) for (int i=first;i<last;++i)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
vector<int> stones(3);
int check(int n){
int lack = 0;
int plus = 0;
for (auto s: stones) {
if (n <= s) {
plus += (s - n) / 2;
} else {
lack += n - s;
}
}
return lack <= plus;
}
int bs(int min, int max){
int mid = (min + max) / 2;
if (mid == min) {
return mid;
} else {
return check(mid) ? bs(mid, max) : bs(min, mid);
}
}
int main(){
REP(i,0,3){ cin >> stones[i]; }
auto max = max_element(stones.begin(), stones.end());
auto min = min_element(stones.begin(), stones.end());
cout << bs(*min, *max) << endl;
}