結果

問題 No.91 赤、緑、青の石
ユーザー yy
提出日時 2016-03-17 22:15:10
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,139 bytes
コンパイル時間 2,155 ms
コンパイル使用メモリ 77,872 KB
実行使用メモリ 55,752 KB
最終ジャッジ日時 2024-04-08 16:46:53
合計ジャッジ時間 5,424 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
54,900 KB
testcase_01 WA -
testcase_02 AC 76 ms
55,000 KB
testcase_03 AC 78 ms
54,892 KB
testcase_04 AC 76 ms
54,996 KB
testcase_05 AC 76 ms
54,904 KB
testcase_06 WA -
testcase_07 AC 55 ms
52,012 KB
testcase_08 WA -
testcase_09 AC 54 ms
53,984 KB
testcase_10 AC 55 ms
53,964 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 79 ms
54,988 KB
testcase_16 AC 53 ms
53,972 KB
testcase_17 AC 55 ms
53,964 KB
testcase_18 AC 54 ms
53,972 KB
testcase_19 AC 53 ms
53,964 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 53 ms
54,008 KB
testcase_24 AC 54 ms
51,896 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] rgbs = br.readLine().split(" ");
        int[] rgb = new int[3];
        for (int i = 0; i < 3; i++) {
            rgb[i] = Integer.parseInt(rgbs[i]);
        }
        while (true) {
            int avg = (rgb[0] + rgb[1] + rgb[2]) / 3;
            if (rgb[0] < avg + 2 && rgb[1] < avg + 2 && rgb[2] < avg + 2) {
                break;
            }
            for (int i = 0; i < 3; i++) {
                while (rgb[i] >= avg + 2) {
                    for (int j = 0; j < 3; j++) {
                        if (j == i) continue;
                        if (rgb[j] <= avg) {
                            rgb[j]++;
                            rgb[i] -= 2;
                            break;
                        }
                    }
                }
            }
        }
        System.out.println(Math.min(Math.min(rgb[0], rgb[1]), rgb[2]));
    }
}
0