結果

問題 No.437 cwwゲーム
ユーザー 💕💖💞💕💖💞
提出日時 2016-11-23 01:47:17
言語 Go
(1.21.3)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,976 bytes
コンパイル時間 14,467 ms
コンパイル使用メモリ 213,672 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-02 13:08:02
合計ジャッジ時間 16,102 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
}
0