結果

問題 No.91 赤、緑、青の石
ユーザー spaciaspacia
提出日時 2016-01-10 05:18:21
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,202 bytes
コンパイル時間 2,223 ms
コンパイル使用メモリ 78,312 KB
実行使用メモリ 37,300 KB
最終ジャッジ日時 2024-04-16 12:23:17
合計ジャッジ時間 5,014 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
37,056 KB
testcase_01 WA -
testcase_02 AC 51 ms
36,964 KB
testcase_03 AC 51 ms
36,728 KB
testcase_04 AC 52 ms
37,032 KB
testcase_05 AC 51 ms
36,632 KB
testcase_06 AC 50 ms
37,068 KB
testcase_07 AC 51 ms
36,964 KB
testcase_08 AC 51 ms
36,900 KB
testcase_09 AC 50 ms
36,876 KB
testcase_10 AC 51 ms
36,892 KB
testcase_11 AC 50 ms
37,064 KB
testcase_12 AC 51 ms
37,068 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 51 ms
36,616 KB
testcase_17 AC 51 ms
37,144 KB
testcase_18 AC 51 ms
36,944 KB
testcase_19 AC 52 ms
36,788 KB
testcase_20 AC 54 ms
37,008 KB
testcase_21 AC 52 ms
36,912 KB
testcase_22 AC 53 ms
37,300 KB
testcase_23 AC 52 ms
36,876 KB
testcase_24 AC 52 ms
36,632 KB
testcase_25 AC 53 ms
37,140 KB
testcase_26 AC 52 ms
36,776 KB
testcase_27 AC 52 ms
37,096 KB
testcase_28 AC 52 ms
36,676 KB
testcase_29 AC 54 ms
36,748 KB
testcase_30 AC 53 ms
36,632 KB
testcase_31 AC 52 ms
36,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static int solve (int[] prob) {
		//out(Arrays.toString(prob));
		if (prob[2] == 0) return 0;
		if (prob[1] == 0) return prob[2] / 5;
		if (prob[0] == 0) {
			if (prob[1] == prob[2]) {
				int m = prob[1] % 4;
				int n = prob[1] / 4 * 2;
				return m == 3 ? n + 1 : n;
			} else if (prob[2] - prob[1] != 1) {
				if (prob[2] % 2 != prob[1] % 2) {
					prob[2] -= 2;
					prob[1]++;
				}
				prob[0] = Math.min((prob[2] - prob[1]) / 2 , prob[1]);
				prob[2] -= prob[0] * 2;
				Arrays.sort(prob);
				return solve(prob);
			} else {
				return prob[2] / 2;
			}
		} else {
			int ret = prob[0];
			prob[1] -= prob[0];
			prob[2] -= prob[0];
			prob[0] = 0;
			return ret + solve(prob);
		}
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		String[] line = br.readLine().split(" ");
		int r = Integer.parseInt(line[0]);
		int g = Integer.parseInt(line[1]);
		int b = Integer.parseInt(line[2]);
		int[] prob = {r , g , b};
		
		Arrays.sort(prob);
		out(solve(prob));
	}
}
0