結果

問題 No.91 赤、緑、青の石
ユーザー ichyoichyo
提出日時 2014-12-07 19:39:26
言語 Go
(1.21.3)
結果
AC  
実行時間 35 ms / 5,000 ms
コード長 724 bytes
コンパイル時間 12,457 ms
コンパイル使用メモリ 213,936 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 12:05:34
合計ジャッジ時間 12,725 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
4,376 KB
testcase_01 AC 17 ms
4,380 KB
testcase_02 AC 24 ms
4,380 KB
testcase_03 AC 19 ms
4,376 KB
testcase_04 AC 25 ms
4,376 KB
testcase_05 AC 19 ms
4,380 KB
testcase_06 AC 15 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 25 ms
4,380 KB
testcase_12 AC 25 ms
4,376 KB
testcase_13 AC 22 ms
4,376 KB
testcase_14 AC 21 ms
4,380 KB
testcase_15 AC 25 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 35 ms
4,380 KB
testcase_26 AC 28 ms
4,380 KB
testcase_27 AC 31 ms
4,380 KB
testcase_28 AC 26 ms
4,376 KB
testcase_29 AC 16 ms
4,376 KB
testcase_30 AC 21 ms
4,376 KB
testcase_31 AC 28 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import "fmt"

func dec(r, g, b *int) bool {
	if *r >= *g && *r >= *b {
		if *r < 2 {
			return false
		}
		*r -= 2
	} else if *g >= *r && *g >= *b {
		if *g < 2 {
			return false
		}
		*g -= 2
	} else {
		if *b < 2 {
			return false
		}
		*b -= 2
	}
	return true
}

func main() {
	var r, g, b int
	fmt.Scan(&r, &g, &b)
	ans := 0
	for {
		need := 0
		if r > 0 {
			r--
		} else {
			need++
		}
		if g > 0 {
			g--
		} else {
			need++
		}
		if b > 0 {
			b--
		} else {
			need++
		}
		ok := true
		for need > 0 {
			if dec(&r, &g, &b) {
				need--
			} else {
				ok = false
				break
			}
		}
		if !ok {
			break
		}
		ans++
	}
	fmt.Println(ans)
}
0