結果

問題 No.91 赤、緑、青の石
ユーザー Grenache
提出日時 2015-11-22 23:54:48
言語 Java
(openjdk 23)
結果
AC  
実行時間 153 ms / 5,000 ms
コード長 879 bytes
コンパイル時間 3,680 ms
コンパイル使用メモリ 74,700 KB
実行使用メモリ 41,648 KB
最終ジャッジ日時 2024-06-24 06:52:31
合計ジャッジ時間 9,597 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;


public class Main_yukicoder91 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[] rgb = new int[3];
        for (int i = 0; i < 3; i++) {
        	rgb[i] = sc.nextInt();
        }
        Arrays.sort(rgb);

        int l = 0;
        int r = 10_000_001;
		while (r > l) {
        	int mid = (r + l) / 2;
        	int value = 0;
        	int value2 = 0;
        	for (int i = 0; i < 3; i++) {
        		if (rgb[i] >= 10_000_000 - mid) {
        			value += (rgb[i] - (10_000_000 - mid)) / 2;
        		} else {
        			value2 += (10_000_000 - mid) - rgb[i];
        		}
        	}
        	if (value >= value2) {
        		r = mid;
        	} else {
        		l = mid + 1;
        	}
        }

        System.out.println(10_000_000 - r);

        sc.close();
    }
}
0