結果

問題 No.91 赤、緑、青の石
ユーザー hikari2004hikari2004
提出日時 2016-04-22 17:33:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 141 ms / 5,000 ms
コード長 1,140 bytes
コンパイル時間 3,342 ms
コンパイル使用メモリ 74,692 KB
実行使用メモリ 56,512 KB
最終ジャッジ日時 2023-09-06 12:20:35
合計ジャッジ時間 8,845 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
56,036 KB
testcase_01 AC 137 ms
56,152 KB
testcase_02 AC 134 ms
55,628 KB
testcase_03 AC 135 ms
55,980 KB
testcase_04 AC 132 ms
55,908 KB
testcase_05 AC 135 ms
55,444 KB
testcase_06 AC 131 ms
55,712 KB
testcase_07 AC 118 ms
55,436 KB
testcase_08 AC 120 ms
55,752 KB
testcase_09 AC 119 ms
56,076 KB
testcase_10 AC 119 ms
56,088 KB
testcase_11 AC 128 ms
56,072 KB
testcase_12 AC 136 ms
55,864 KB
testcase_13 AC 135 ms
56,140 KB
testcase_14 AC 134 ms
55,948 KB
testcase_15 AC 137 ms
56,512 KB
testcase_16 AC 119 ms
56,192 KB
testcase_17 AC 119 ms
55,744 KB
testcase_18 AC 120 ms
55,968 KB
testcase_19 AC 118 ms
55,952 KB
testcase_20 AC 120 ms
56,092 KB
testcase_21 AC 120 ms
55,768 KB
testcase_22 AC 120 ms
55,676 KB
testcase_23 AC 120 ms
56,196 KB
testcase_24 AC 120 ms
55,624 KB
testcase_25 AC 139 ms
56,012 KB
testcase_26 AC 137 ms
55,752 KB
testcase_27 AC 118 ms
55,964 KB
testcase_28 AC 130 ms
55,680 KB
testcase_29 AC 129 ms
56,184 KB
testcase_30 AC 131 ms
55,708 KB
testcase_31 AC 135 ms
55,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicorder;

import java.util.Scanner;


//TODO 見直し
public class No_91 {

	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(r,g,b));
	}

	public static int solve(int r, int g, int b){
		int basic = Math.min(Math.min(r,g),b); //各石の最低値
		int red = r - basic;
		int green = g - basic;
		int blue = b - basic;
		int acce = basic; //暫定的なアクセサリーの数は変数basic


		while(true){
			if(red == 0){
				if(Math.max(green, blue) > 2){
					if(blue > green){
						blue -= 2;
					}else{
						green -= 2;
					}
				}else{
					break;
				}
				red++;
			}
			if(green == 0){
				if(Math.max(red, blue) > 2){
					if(blue > red){
						blue -= 2;
					}else{
						red -= 2;
					}
				}else{
					break;
				}
				green++;
			}
			if(blue == 0){
				if(Math.max(red, green) > 2){
					if(red > green){
						red -= 2;
					}else{
						green -= 2;
					}
				}else{
					break;
				}
				blue++;
			}
			red--;
			green--;
			blue--;
			acce++;
		}

		return acce;
	}
}
0