結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
55,984 KB
testcase_01 AC 136 ms
56,100 KB
testcase_02 AC 134 ms
55,828 KB
testcase_03 AC 134 ms
55,932 KB
testcase_04 AC 134 ms
54,012 KB
testcase_05 AC 134 ms
55,844 KB
testcase_06 AC 130 ms
55,776 KB
testcase_07 AC 120 ms
56,260 KB
testcase_08 AC 118 ms
55,544 KB
testcase_09 AC 119 ms
55,824 KB
testcase_10 AC 120 ms
56,332 KB
testcase_11 AC 130 ms
56,160 KB
testcase_12 AC 136 ms
55,516 KB
testcase_13 AC 134 ms
55,516 KB
testcase_14 AC 134 ms
53,868 KB
testcase_15 AC 138 ms
55,916 KB
testcase_16 AC 121 ms
56,144 KB
testcase_17 AC 120 ms
55,912 KB
testcase_18 AC 120 ms
55,516 KB
testcase_19 AC 120 ms
56,036 KB
testcase_20 AC 120 ms
55,784 KB
testcase_21 AC 120 ms
54,332 KB
testcase_22 AC 125 ms
56,036 KB
testcase_23 AC 119 ms
55,668 KB
testcase_24 AC 119 ms
56,008 KB
testcase_25 AC 139 ms
56,064 KB
testcase_26 AC 137 ms
56,080 KB
testcase_27 AC 117 ms
55,980 KB
testcase_28 AC 131 ms
55,980 KB
testcase_29 AC 128 ms
56,616 KB
testcase_30 AC 130 ms
56,048 KB
testcase_31 AC 135 ms
56,416 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 base = Math.min(Math.min(r,g),b);
		int red=r-base,green=g-base,blue=b-base;
		int sum = base;
		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