結果
問題 | No.91 赤、緑、青の石 |
ユーザー |
|
提出日時 | 2014-12-07 19:39:26 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 28 ms / 5,000 ms |
コード長 | 724 bytes |
コンパイル時間 | 14,886 ms |
コンパイル使用メモリ | 233,460 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 06:42:54 |
合計ジャッジ時間 | 15,729 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
ソースコード
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) }