結果

問題 No.91 赤、緑、青の石
ユーザー kou6839kou6839
提出日時 2014-12-08 22:38:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 919 bytes
コンパイル時間 2,071 ms
コンパイル使用メモリ 73,372 KB
実行使用メモリ 57,696 KB
最終ジャッジ日時 2023-09-06 12:08:48
合計ジャッジ時間 7,001 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
55,320 KB
testcase_01 AC 116 ms
55,516 KB
testcase_02 AC 115 ms
56,260 KB
testcase_03 AC 110 ms
55,868 KB
testcase_04 AC 113 ms
55,872 KB
testcase_05 AC 113 ms
55,644 KB
testcase_06 AC 110 ms
55,892 KB
testcase_07 AC 110 ms
55,660 KB
testcase_08 AC 113 ms
55,972 KB
testcase_09 AC 117 ms
55,416 KB
testcase_10 AC 113 ms
56,140 KB
testcase_11 AC 118 ms
55,576 KB
testcase_12 AC 114 ms
55,556 KB
testcase_13 AC 118 ms
57,696 KB
testcase_14 AC 116 ms
55,648 KB
testcase_15 AC 114 ms
55,356 KB
testcase_16 AC 115 ms
54,400 KB
testcase_17 AC 117 ms
55,928 KB
testcase_18 AC 113 ms
55,984 KB
testcase_19 AC 115 ms
55,772 KB
testcase_20 AC 111 ms
55,320 KB
testcase_21 AC 117 ms
55,380 KB
testcase_22 AC 118 ms
55,584 KB
testcase_23 AC 119 ms
55,612 KB
testcase_24 AC 114 ms
55,516 KB
testcase_25 AC 119 ms
55,836 KB
testcase_26 AC 121 ms
55,820 KB
testcase_27 AC 121 ms
55,768 KB
testcase_28 AC 128 ms
55,964 KB
testcase_29 AC 126 ms
55,644 KB
testcase_30 AC 125 ms
56,032 KB
testcase_31 AC 127 ms
55,632 KB
権限があれば一括ダウンロードができます

ソースコード

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