結果
| 問題 |
No.91 赤、緑、青の石
|
| ユーザー |
|
| 提出日時 | 2017-03-09 15:19:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 740 bytes |
| コンパイル時間 | 1,375 ms |
| コンパイル使用メモリ | 160,648 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-24 07:04:20 |
| 合計ジャッジ時間 | 2,406 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 28 |
ソースコード
#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;
}