結果

問題 No.920 あかあお
ユーザー hirogahiroga
提出日時 2019-12-29 22:54:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,612 bytes
コンパイル時間 4,434 ms
コンパイル使用メモリ 78,700 KB
実行使用メモリ 37,144 KB
最終ジャッジ日時 2024-04-24 11:54:44
合計ジャッジ時間 5,079 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
37,076 KB
testcase_01 AC 52 ms
36,788 KB
testcase_02 AC 53 ms
36,684 KB
testcase_03 AC 52 ms
36,976 KB
testcase_04 AC 52 ms
37,120 KB
testcase_05 AC 53 ms
37,032 KB
testcase_06 AC 52 ms
36,664 KB
testcase_07 AC 51 ms
36,960 KB
testcase_08 AC 52 ms
37,144 KB
testcase_09 AC 54 ms
36,808 KB
testcase_10 AC 53 ms
36,852 KB
testcase_11 AC 53 ms
37,096 KB
testcase_12 AC 54 ms
36,700 KB
testcase_13 AC 51 ms
36,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// https://yukicoder.me/problems/no/920

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class No920 {

    public static String output = "";

    public static void main(final String[] args) {

        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final List<Integer> nums = new ArrayList<Integer>();

        String line;
        try {
            line = br.readLine().trim();

            final String[] numTokens = line.split(" ");
            for (final String numToken : numTokens) {
                nums.add(Integer.valueOf(numToken));
            }
        } catch (final IOException e) {
            e.printStackTrace();
        }

        final Solver solver = new Solver();
        solver.solve(nums);

        // Print the final output
        System.out.println(output);
    }

}

class Solver {
    public void solve(final List<Integer> input) {
        final int red = input.get(0);
        final int blue = input.get(1);
        final int white = input.get(2);

        if (Math.abs(red - blue) >= white) {
            // System.out.println("赤玉と青玉の差が大きすぎるので、白玉を少ない方の玉にすべて変換するケース");
            No920.output = String.valueOf(Math.min(red, blue) + white);
        } else {
            // System.out.println("赤玉と青玉の差が少ないので、白玉を均等に割り振るケース");
            No920.output = String.valueOf((red + blue + white) / 2);
        }
    }
}
0