結果
問題 |
No.437 cwwゲーム
|
ユーザー |
![]() |
提出日時 | 2016-11-23 01:47:17 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,976 bytes |
コンパイル時間 | 17,387 ms |
コンパイル使用メモリ | 225,248 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-12 08:40:27 |
合計ジャッジ時間 | 16,661 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
package main import ( "bufio" "fmt" _ "math" _ "math/big" "os" _ "reflect" _ "regexp" "strconv" _ "strings" ) func callable(ns []string, bs []bool) int64 { res := int64(0) for i := 0; i < len(ns); i++ { if bs[i] == true { continue } for j := i + 1; j < len(ns); j++ { if bs[j] == true { continue } for k := j + 1; k < len(ns); k++ { if bs[k] == true { continue } if ns[i] != "0" && ns[i] != ns[j] && ns[j] == ns[k] { x, _ := strconv.ParseInt(ns[i]+ns[j]+ns[k], 10, 64) bs[i], bs[j], bs[k] = true, true, true comp := x + callable(ns, bs) if res < comp { res = comp } bs[i], bs[j], bs[k] = false, false, false } } } } return res } func main() { scanner := bufio.NewScanner(os.Stdin) th := 0 lines := []string{} for scanner.Scan() { th += 1 text := scanner.Text() lines = append(lines, text) if th == 1 { break } } bs := []bool{} tn := lines[0] ns := []string{} for _, x := range []rune(tn) { ns = append(ns, string(x)) bs = append(bs, false) } fmt.Println(callable(ns, bs)) }