結果

問題 No.91 赤、緑、青の石
ユーザー htensai
提出日時 2019-12-05 19:11:11
言語 Java
(openjdk 23)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 861 bytes
コンパイル時間 2,033 ms
コンパイル使用メモリ 77,384 KB
実行使用メモリ 54,508 KB
最終ジャッジ日時 2024-06-24 07:23:10
合計ジャッジ時間 7,252 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] arr = new int[3];
		for (int i = 0; i < 3; i++) {
		    arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		int count = arr[0];
		arr[1] -= arr[0];
		arr[2] -= arr[0];
		arr[0] = 0;
		int left = 0;
		int right = arr[2];
		while (right - left > 1) {
		    int m = (left + right) / 2;
		    int a = arr[0] - m;
		    int b = arr[1] - m;
		    int c = arr[2] - m;
		    if (b < 0) {
		        if (a + b + c / 2 >= 0) {
		            left = m;
		        } else {
		            right = m;
		        }
		    } else if (a < 0) {
		        if (b / 2 + c / 2 + a >= 0) {
		            left = m;
		        } else {
		            right = m;
		        }
		    } else {
		        left = m;
		    }
		}
		System.out.println(count + left);
   }
}

0