結果

問題 No.91 赤、緑、青の石
ユーザー spaciaspacia
提出日時 2016-06-02 18:30:19
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,189 bytes
コンパイル時間 2,228 ms
コンパイル使用メモリ 77,416 KB
実行使用メモリ 41,752 KB
最終ジャッジ日時 2024-04-16 23:16:48
合計ジャッジ時間 7,577 ms
ジャッジサーバーID
(参考情報)
judge5 / 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,296 KB
testcase_08 AC 128 ms
41,448 KB
testcase_09 AC 128 ms
41,196 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 128 ms
41,276 KB
testcase_17 AC 131 ms
41,232 KB
testcase_18 AC 131 ms
41,584 KB
testcase_19 AC 128 ms
41,432 KB
testcase_20 AC 133 ms
41,420 KB
testcase_21 AC 137 ms
41,564 KB
testcase_22 AC 136 ms
41,292 KB
testcase_23 AC 135 ms
41,280 KB
testcase_24 AC 134 ms
41,444 KB
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) {

		Arrays.sort(nums);

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

		if (nums[0] != 0) {
			nums[1] -= nums[0];
			nums[2] -= nums[0];
			//System.out.println(nums[0]);
			return nums[0] + solve(new int[]{0, nums[1], nums[2]});
		}

		if (nums[2] == 0) return 0;

		if (nums[1] == 0) return nums[2] / 5;

		if (nums[2] - nums[1] >= 2) {
			int sub = nums[2] - nums[1];
			int sub_half = sub / 2;
			if (sub_half <= nums[1]) {
				nums[2] -= sub_half * 2;
				nums[1] -= sub_half;
				//System.out.println(sub_half);
				return sub_half + solve(nums);
			} else {
				//System.out.println(nums[1]);
				return nums[1] + solve(new int[]{0, 0, nums[2] - nums[1]});
			}
		} 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 == 0 ? nums[2] / 2 : (nums[2] - 1) / 2;
	}

}
0