結果

問題 No.91 赤、緑、青の石
ユーザー rf141rf141
提出日時 2015-12-20 17:23:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 143 ms / 5,000 ms
コード長 935 bytes
コンパイル時間 2,107 ms
コンパイル使用メモリ 74,036 KB
実行使用メモリ 56,640 KB
最終ジャッジ日時 2023-09-06 12:16:06
合計ジャッジ時間 7,346 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
55,736 KB
testcase_01 AC 143 ms
55,836 KB
testcase_02 AC 141 ms
55,852 KB
testcase_03 AC 142 ms
56,036 KB
testcase_04 AC 141 ms
55,820 KB
testcase_05 AC 143 ms
55,800 KB
testcase_06 AC 137 ms
56,008 KB
testcase_07 AC 118 ms
55,712 KB
testcase_08 AC 120 ms
56,640 KB
testcase_09 AC 120 ms
55,768 KB
testcase_10 AC 122 ms
55,992 KB
testcase_11 AC 140 ms
55,716 KB
testcase_12 AC 143 ms
55,484 KB
testcase_13 AC 137 ms
56,564 KB
testcase_14 AC 139 ms
56,004 KB
testcase_15 AC 143 ms
56,416 KB
testcase_16 AC 118 ms
55,904 KB
testcase_17 AC 119 ms
55,996 KB
testcase_18 AC 120 ms
56,304 KB
testcase_19 AC 119 ms
55,652 KB
testcase_20 AC 120 ms
56,008 KB
testcase_21 AC 122 ms
55,820 KB
testcase_22 AC 121 ms
56,292 KB
testcase_23 AC 119 ms
55,456 KB
testcase_24 AC 121 ms
56,208 KB
testcase_25 AC 140 ms
56,156 KB
testcase_26 AC 139 ms
55,480 KB
testcase_27 AC 134 ms
56,096 KB
testcase_28 AC 136 ms
55,968 KB
testcase_29 AC 134 ms
55,896 KB
testcase_30 AC 132 ms
55,896 KB
testcase_31 AC 135 ms
56,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;
public class Main{
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();
		int g = scan.nextInt();
		int b = scan.nextInt();
		System.out.println(Calc(r,g,b));
	}

	public static int Calc(int r,int g,int b){
		int red=r,green=g,blue=b;
		int sum = 0;
		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(green > red){
						green -= 2;
					}else{
						red -= 2;
					}
				}else{
					break;
				}
				blue++;
			}
			red--;green--;blue--;
			sum++;
		}
		return sum;

	}
}
0