結果

問題 No.91 赤、緑、青の石
ユーザー 0w10w1
提出日時 2016-11-20 16:36:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 5,000 ms
コード長 918 bytes
コンパイル時間 1,553 ms
コンパイル使用メモリ 166,740 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 12:25:01
合計ジャッジ時間 3,007 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
4,380 KB
testcase_01 AC 11 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 14 ms
4,376 KB
testcase_04 AC 7 ms
4,376 KB
testcase_05 AC 13 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 9 ms
4,380 KB
testcase_13 AC 21 ms
4,380 KB
testcase_14 AC 6 ms
4,380 KB
testcase_15 AC 17 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 36 ms
4,376 KB
testcase_26 AC 30 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 26 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

signed main(){
  int R, G, B; cin >> R >> G >> B;
  int ans = min( { R, G, B } );
  R -= ans, G -= ans, B -= ans;
  int v[ 3 ] = { R, G, B }; sort( v, v + 3 );
  if( R + G > 0 and G + B > 0 and R + B > 0 ){
    int lb = 0, rb = ( int ) 1e7;
    int z = 0;
    while( lb <= rb ){
      int mid = lb + rb >> 1;
      int ok = 0;
      for( int i = 0; i <= mid; ++i ){
        if( v[ 1 ] - 2 * i < mid )
          break;
        if( v[ 2 ] - 2 * ( mid - i ) >= mid )
          ok = 1;
      }
      if( ok )
        z = mid, lb = mid + 1;
      else
        rb = mid - 1;
    }
    ans += z;
    for( int i = 0; i <= z; ++i ){
      if( v[ 1 ] - 2 * i < z )
        break;
      if( v[ 2 ] - 2 * ( z - i ) >= z ){
        v[ 1 ] -= 2 * i + z, v[ 2 ] -= 2 * ( z - i ) + z;
      }
    }
  }
  ans += max( { v[ 0 ], v[ 1 ], v[ 2 ] } ) / 5;
  cout << ans << endl;
  return 0;
}
0