結果
問題 | No.91 赤、緑、青の石 |
ユーザー |
![]() |
提出日時 | 2015-08-08 15:43:52 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,015 bytes |
コンパイル時間 | 923 ms |
コンパイル使用メモリ | 84,916 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 06:50:46 |
合計ジャッジ時間 | 1,943 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
ソースコード
#include <cstdio>#include <cstring>#include <cmath>#include <climits>#include <iostream>#include <iomanip>#include <list>#include <stack>#include <queue>#include <vector>#include <map>#include <set>#include <string>#include <utility>#include <algorithm>#include <numeric>#include <functional>#define FOR(i,a,b) for (int i=(a);i<(b);i++)#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)#define REP(i,n) for (int i=0;i<(n);i++)#define RREP(i,n) for (int i=(n)-1;i>=0;i--)#define ALL(a) (a).begin(),(a).end()using namespace std;typedef long long ll;int R, G, B;bool ok(int n) {int shortage, surplus;shortage = max(0, n-R) + max(0, n-G) + max(0, n-B);surplus = max(R-n, 0) / 2 + max(G-n, 0) / 2 + max(B-n, 0) / 2;return surplus >= shortage;}int main(int argc, char *argv[]){cin.tie(0);ios::sync_with_stdio(false);cin >> R >> G >> B;int ret = 0;for (int i = 24; i >= 0; i--)if (ok(ret + (1<<i)))ret += 1<<i;cout << ret << endl;return 0;}