結果

問題 No.91 赤、緑、青の石
ユーザー goodbaton
提出日時 2015-08-04 22:05:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 950 bytes
コンパイル時間 806 ms
コンパイル使用メモリ 71,840 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-24 06:50:41
合計ジャッジ時間 1,804 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |     scanf("%d%d%d",&R,&G,&B);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>

typedef long long ll;
using namespace std;

#define mod 1000000009
#define INF 10000000
#define LLINF 2000000000000000000LL

#define SIZE 101


int main(){
    int R,G,B,ans=0;
    
    scanf("%d%d%d",&R,&G,&B);
    
    ans+=min(R,min(G,B));
    
    R-=ans;
    G-=ans;
    B-=ans;
    
    int l=0,r=max(R,max(G,B)),mid,rest;
    
    while(l<r){
        mid = (l+r+1)/2;
        rest=0;
        
        rest+=max(R-mid,0)/2;
        rest+=max(G-mid,0)/2;
        rest+=max(B-mid,0)/2;
        
        rest-=max(mid-R,0);
        rest-=max(mid-G,0);
        rest-=max(mid-B,0);
        
        if(rest>=0){
            l=mid;
        }else{
            r=mid-1;
        }
    }
    
    printf("%d\n",ans+l);
    
    return 0;
}
0