結果

問題 No.91 赤、緑、青の石
ユーザー tentententen
提出日時 2020-12-07 18:05:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 5,000 ms
コード長 832 bytes
コンパイル時間 3,994 ms
コンパイル使用メモリ 70,988 KB
実行使用メモリ 57,788 KB
最終ジャッジ日時 2023-09-06 12:52:42
合計ジャッジ時間 6,928 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,860 KB
testcase_01 AC 119 ms
55,948 KB
testcase_02 AC 118 ms
55,724 KB
testcase_03 AC 119 ms
55,876 KB
testcase_04 AC 117 ms
55,944 KB
testcase_05 AC 118 ms
56,132 KB
testcase_06 AC 118 ms
55,864 KB
testcase_07 AC 119 ms
56,236 KB
testcase_08 AC 119 ms
55,660 KB
testcase_09 AC 120 ms
57,152 KB
testcase_10 AC 120 ms
56,112 KB
testcase_11 AC 120 ms
56,104 KB
testcase_12 AC 120 ms
55,744 KB
testcase_13 AC 120 ms
56,296 KB
testcase_14 AC 119 ms
55,932 KB
testcase_15 AC 119 ms
55,788 KB
testcase_16 AC 117 ms
55,784 KB
testcase_17 AC 118 ms
56,200 KB
testcase_18 AC 119 ms
56,020 KB
testcase_19 AC 119 ms
55,796 KB
testcase_20 AC 120 ms
55,932 KB
testcase_21 AC 118 ms
55,672 KB
testcase_22 AC 119 ms
55,612 KB
testcase_23 AC 123 ms
55,764 KB
testcase_24 AC 120 ms
55,700 KB
testcase_25 AC 121 ms
55,892 KB
testcase_26 AC 119 ms
55,888 KB
testcase_27 AC 120 ms
56,196 KB
testcase_28 AC 120 ms
55,616 KB
testcase_29 AC 120 ms
55,780 KB
testcase_30 AC 118 ms
56,208 KB
testcase_31 AC 119 ms
57,788 KB
権限があれば一括ダウンロードができます

ソースコード

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();
        }
        int left = 0;
        int right = Integer.MAX_VALUE / 10;
        while (right - left > 1) {
            int m = (left + right) / 2;
            int minus = 0;
            int plus = 0;
            for (int i = 0; i < 3; i++) {
                if (arr[i] < m) {
                    minus += m - arr[i];
                } else {
                    plus += (arr[i] - m) / 2;
                }
            }
            if (plus >= minus) {
                left = m;
            } else {
                right = m;
            }
        }
        System.out.println(left);
    }
}
0