結果

問題 No.91 赤、緑、青の石
ユーザー r.suzukir.suzuki
提出日時 2015-12-30 22:45:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 175 ms / 5,000 ms
コード長 1,115 bytes
コンパイル時間 3,208 ms
コンパイル使用メモリ 74,936 KB
実行使用メモリ 57,816 KB
最終ジャッジ日時 2023-09-06 12:16:32
合計ジャッジ時間 9,287 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 165 ms
55,512 KB
testcase_01 AC 156 ms
56,252 KB
testcase_02 AC 162 ms
56,028 KB
testcase_03 AC 155 ms
55,756 KB
testcase_04 AC 163 ms
56,052 KB
testcase_05 AC 159 ms
54,036 KB
testcase_06 AC 152 ms
55,912 KB
testcase_07 AC 117 ms
56,220 KB
testcase_08 AC 115 ms
56,008 KB
testcase_09 AC 117 ms
55,492 KB
testcase_10 AC 115 ms
56,264 KB
testcase_11 AC 173 ms
55,832 KB
testcase_12 AC 170 ms
55,708 KB
testcase_13 AC 161 ms
55,468 KB
testcase_14 AC 163 ms
57,816 KB
testcase_15 AC 170 ms
55,460 KB
testcase_16 AC 119 ms
55,672 KB
testcase_17 AC 123 ms
56,136 KB
testcase_18 AC 120 ms
55,456 KB
testcase_19 AC 122 ms
56,064 KB
testcase_20 AC 117 ms
56,244 KB
testcase_21 AC 117 ms
55,532 KB
testcase_22 AC 123 ms
55,816 KB
testcase_23 AC 127 ms
55,684 KB
testcase_24 AC 122 ms
55,652 KB
testcase_25 AC 175 ms
55,984 KB
testcase_26 AC 164 ms
55,656 KB
testcase_27 AC 165 ms
56,036 KB
testcase_28 AC 171 ms
56,072 KB
testcase_29 AC 161 ms
55,704 KB
testcase_30 AC 149 ms
56,100 KB
testcase_31 AC 161 ms
55,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Stone {
	int count;
	static int jewelry;

	Stone(int i) {
		this.count = i;
	}

	static void makeJewelry(Stone r, Stone g, Stone b) {
		r.count--;
		g.count--;
		b.count--;
		jewelry++;
	}

	static boolean checkJewelry(Stone r, Stone g, Stone b) {
		if (r.count >= 1 && g.count >= 1 && b.count >= 1) {
			return true;
		} else {
			return false;
		}
	}

	static void adjust(Stone r, Stone g, Stone b) {
		Stone x = r.count > g.count ? r : g;
		Stone max = x.count > b.count ? x : b;
		Stone n = r.count < g.count ? r : g;
		Stone min = n.count < b.count ? n : b;
		max.count -= 2;
		min.count += 1;
	}
}

public class No_91 {

	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		Stone red = new Stone(sc.nextInt());
		Stone green = new Stone(sc.nextInt());
		Stone blue = new Stone(sc.nextInt());

		while (red.count >= 0 && green.count >= 0 && blue.count >= 0) {
			if (Stone.checkJewelry(red, green, blue)) {
				Stone.makeJewelry(red, green, blue);
				;
			} else {
				Stone.adjust(red, green, blue);
			}
		}
		System.out.println(Stone.jewelry);

	}

}
0