結果

問題 No.91 赤、緑、青の石
ユーザー jp_stejp_ste
提出日時 2016-05-26 05:18:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 159 ms / 5,000 ms
コード長 1,230 bytes
コンパイル時間 2,067 ms
コンパイル使用メモリ 73,912 KB
実行使用メモリ 56,352 KB
最終ジャッジ日時 2023-09-06 12:21:41
合計ジャッジ時間 7,689 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,784 KB
testcase_01 AC 131 ms
56,056 KB
testcase_02 AC 123 ms
56,048 KB
testcase_03 AC 129 ms
55,872 KB
testcase_04 AC 124 ms
55,856 KB
testcase_05 AC 130 ms
56,096 KB
testcase_06 AC 120 ms
56,236 KB
testcase_07 AC 109 ms
56,040 KB
testcase_08 AC 117 ms
55,928 KB
testcase_09 AC 112 ms
56,020 KB
testcase_10 AC 110 ms
55,856 KB
testcase_11 AC 121 ms
55,896 KB
testcase_12 AC 135 ms
56,100 KB
testcase_13 AC 129 ms
55,816 KB
testcase_14 AC 128 ms
55,584 KB
testcase_15 AC 129 ms
56,192 KB
testcase_16 AC 112 ms
55,760 KB
testcase_17 AC 111 ms
55,820 KB
testcase_18 AC 112 ms
56,012 KB
testcase_19 AC 116 ms
55,772 KB
testcase_20 AC 109 ms
55,856 KB
testcase_21 AC 106 ms
55,892 KB
testcase_22 AC 108 ms
56,352 KB
testcase_23 AC 108 ms
55,808 KB
testcase_24 AC 112 ms
55,988 KB
testcase_25 AC 159 ms
55,392 KB
testcase_26 AC 140 ms
56,008 KB
testcase_27 AC 108 ms
55,764 KB
testcase_28 AC 121 ms
55,800 KB
testcase_29 AC 126 ms
56,076 KB
testcase_30 AC 130 ms
55,808 KB
testcase_31 AC 139 ms
56,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scan = new Scanner(System.in)) {
            int v[] = new int[3];
            v[0] = Integer.parseInt(scan.next());
            v[1] = Integer.parseInt(scan.next());
            v[2] = Integer.parseInt(scan.next());
            
            while(true) {
                if(v[0] == v[1] && v[0] == v[2]) {
                    System.out.println(v[0]);
                    return;
                }
                
                int maxI = 0;
                int minI = 0;
                int max = v[maxI];
                int min = v[minI];
                for(int i=1; i<3; i++) {
                    if(max < v[i]) {
                        max = v[i];
                        maxI = i;
                    }
                    if(min > v[i]) {
                        min = v[i];
                        minI = i;
                    }
                }
                
                if(max - min == 1) {
                    System.out.println(min);
                    return;
                }
                
                v[maxI] -= 2;
                v[minI] += 1;
            }
        }
    }
}
0