結果

問題 No.920 あかあお
ユーザー hirogahiroga
提出日時 2019-12-29 22:47:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,597 bytes
コンパイル時間 3,662 ms
コンパイル使用メモリ 78,280 KB
実行使用メモリ 37,148 KB
最終ジャッジ日時 2024-04-24 11:45:21
合計ジャッジ時間 5,080 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
37,040 KB
testcase_01 AC 52 ms
37,008 KB
testcase_02 AC 52 ms
36,996 KB
testcase_03 AC 54 ms
36,664 KB
testcase_04 AC 52 ms
36,544 KB
testcase_05 AC 52 ms
36,988 KB
testcase_06 AC 52 ms
36,612 KB
testcase_07 AC 52 ms
36,876 KB
testcase_08 AC 52 ms
37,148 KB
testcase_09 AC 52 ms
36,864 KB
testcase_10 AC 53 ms
36,540 KB
testcase_11 AC 52 ms
36,828 KB
testcase_12 AC 52 ms
36,856 KB
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

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(blue + white);
        } else {
            // System.out.println("赤玉と青玉の差が少ないので、白玉を均等に割り振るケース");
            No920.output = String.valueOf((red + blue + white) / 2);
        }
    }
}
0