結果
問題 | No.91 赤、緑、青の石 |
ユーザー |
|
提出日時 | 2018-11-25 18:08:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 623 bytes |
コンパイル時間 | 1,506 ms |
コンパイル使用メモリ | 167,868 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 07:17:18 |
合計ジャッジ時間 | 2,458 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h>using namespace std;int stones[3];bool can(int x){int rem = 0, need = 0;for(int i = 0; i < 3; i++) {if(stones[i] > x) {rem += (stones[i] - x) / 2;}else {need += x - stones[i];}}if(rem >= need) return true;else return false;}int main(){ios::sync_with_stdio(false);cin.tie(0);cin >> stones[0] >> stones[1] >> stones[2];int left = 0, right = 10000000;while(right - left > 1) {int mid = left + (right - left) / 2;if(can(mid)) left = mid;else right = mid;}cout << (can(right) ? right : left) << endl;return 0;}