結果

問題 No.91 赤、緑、青の石
ユーザー kano_town
提出日時 2014-12-07 19:30:15
言語 Java
(openjdk 23)
結果
AC  
実行時間 165 ms / 5,000 ms
コード長 757 bytes
コンパイル時間 3,725 ms
コンパイル使用メモリ 76,452 KB
実行使用メモリ 54,484 KB
最終ジャッジ日時 2024-06-24 06:43:05
合計ジャッジ時間 9,428 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yukicoder91 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long r = sc.nextLong(), g = sc.nextLong(), b = sc.nextLong();
		long sum = (r + g + b) / 3;
		long res = 0;
		while (true) {
			if (r == 0) {
				if (Math.max(b, g) > 2) {
					if (b > g) b -= 2;
					else g -= 2;
				}
				else break;
				r++;
			}
			if (g == 0) {
				if (Math.max(r, b) > 2) {
					if (r > b) r -= 2;
					else b -= 2;
				}
				else break;
				g++;
			}
			if (b == 0) {
				if (Math.max(r, g) > 2) {
					if (r > g) r -= 2;
					else g -= 2;
				}
				else break;
				b++;
			}
			r--;
			g--;
			b--;
			res++;
		}
		System.out.println("" + res);

	}
}
0