結果

問題 No.91 赤、緑、青の石
ユーザー kou6839
提出日時 2014-12-08 22:38:02
言語 Java
(openjdk 23)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 919 bytes
コンパイル時間 2,265 ms
コンパイル使用メモリ 76,724 KB
実行使用メモリ 54,360 KB
最終ジャッジ日時 2024-06-24 06:46:05
合計ジャッジ時間 7,232 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int min = Math.min(r, Math.min(g,b));
        int max = Math.max(r, Math.max(g,b));
        while(min<=max){
        	int temp=(min+max)/2;
        	int count=0;
        	if(temp>r){
        		count-=(temp-r);
        	}else{
        		count+=(r-temp)/2;
        	}
        	if(temp>g){
        		count-=(temp-g);
        	}else{
        		count+=(g-temp)/2;
        	}
        	if(temp>b){
        		count-=(temp-b);
        	}else{
        		count+=(b-temp)/2;
        	}
        	if(count>=0){
        		min=temp+1;
        	}else{
        		max=temp-1;
        	}
        }
        System.out.println(Math.min(min,max));
    }
}
0