結果

問題 No.161 制限ジャンケン
ユーザー GoryudyumaGoryudyuma
提出日時 2015-06-29 16:46:05
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,636 bytes
コンパイル時間 10,851 ms
コンパイル使用メモリ 222,628 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 02:29:08
合計ジャッジ時間 11,845 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
        "bufio"
        "fmt"
        "math"
        "os"
        "strconv"
)

func nextInt() int {
        i, e := strconv.Atoi(nextString())
        if e != nil {
                panic(e)
        }
        return i
}

func nextFloat() float64 {
        f, e := strconv.ParseFloat(nextString(), 64)
        if e != nil {
                panic(e)
        }
        return f
}

func nextString() string {
        var sc = bufio.NewScanner(os.Stdin)
        sc.Split(bufio.ScanWords)
        sc.Scan()
        return sc.Text()
}

func main() {
        var G, C, P float64
        fmt.Scan(&G)
        fmt.Scan(&C)
        fmt.Scan(&P)
        S := nextString()
        var G2, C2, P2 float64
        for i := 0; i < len(S); i++ {
                if S[i] == 'G' {
                        G2++
                } else if S[i] == 'C' {
                        C2++
                } else {
                        P2++
                }
        }
        fmt.Printf("%v %v %v\n", G2, C2, P2)
        ans := 0.0
        x := math.Min(G, C2)
        G -= x
        C2 -= x

        ans += x * 3
        x = 0.0

        x += math.Min(C, P2)
        C -= x
        P2 -= x

        ans += x * 3
        x = 0.0

        x += math.Min(P, G2)
        P -= x
        G2 -= x

        ans += x * 3
        x = 0.0

        x += math.Min(G, G2)
        G -= x
        G2 -= x

        ans += x
        x = 0.0

        x += math.Min(C, C2)
        C -= x
        C2 -= x

        ans += x
        x = 0.0

        x += math.Min(P, P2)
        P -= x
        P2 -= x

        ans += x
        x = 0.0

        fmt.Println(ans)
}
0