結果

問題 No.91 赤、緑、青の石
ユーザー y
提出日時 2016-03-17 22:29:31
言語 Java
(openjdk 23)
結果
AC  
実行時間 118 ms / 5,000 ms
コード長 1,049 bytes
コンパイル時間 2,290 ms
コンパイル使用メモリ 77,144 KB
実行使用メモリ 51,176 KB
最終ジャッジ日時 2024-06-24 06:57:01
合計ジャッジ時間 6,204 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().split(" ");
        int[] n = new int[3];
        for (int i = 0; i < 3; i++) {
            n[i] = Integer.parseInt(s[i]);
        }
        while (true) {
            int max = 0;
            int maxi = 0;
            int min = Integer.MAX_VALUE;
            int mini = 0;
            for (int i = 0; i < 3; i++) {
                if (max < n[i]) {
                    max = n[i];
                    maxi = i;
                }
                if (min > n[i]) {
                    min = n[i];
                    mini = i;
                }
            }
            if (max - min < 2) break;
            n[maxi] -= 2;
            n[mini]++;
        }
        System.out.println(Math.min(Math.min(n[0], n[1]), n[2]));
    }
}
0