結果

問題 No.91 赤、緑、青の石
ユーザー spaciaspacia
提出日時 2016-06-02 17:41:03
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 878 bytes
コンパイル時間 2,393 ms
コンパイル使用メモリ 77,800 KB
実行使用メモリ 41,808 KB
最終ジャッジ日時 2024-04-16 23:13:41
合計ジャッジ時間 7,868 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 133 ms
41,488 KB
testcase_08 AC 130 ms
41,392 KB
testcase_09 AC 134 ms
41,392 KB
testcase_10 AC 133 ms
41,272 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 130 ms
41,268 KB
testcase_17 AC 131 ms
41,156 KB
testcase_18 AC 132 ms
41,552 KB
testcase_19 AC 132 ms
41,392 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 132 ms
41,416 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(solve(new int[]{r, g, b}));

		sc.close();

	}

	public static int solve (int[] nums) {

		//System.out.println(Arrays.toString(nums));

		Arrays.sort(nums);

		int ret = nums[0];
		nums[1] -= nums[0];
		nums[2] -= nums[0];

		if (nums[2] == 0)
			return ret;
		else if (nums[1] == 0)
			return ret + nums[2] / 5;
		else if (nums[2] - nums[1] >= 2) {
			int sub = nums[2] - nums[1];
			ret += sub / 2;
			nums[2] -= sub;
			return ret + solve(nums);
		} else if (nums[2] - nums[1] == 1)
			return nums[2] % 2 == 1 ? (nums[2] - 1) / 2 : (nums[1] - 1) / 2;
		else
			return nums[2] % 4 == 3 ? nums[2] / 4 + 1 : nums[2] / 4;
	}

}
0