結果

問題 No.161 制限ジャンケン
ユーザー GoryudyumaGoryudyuma
提出日時 2015-06-29 16:48:38
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,495 bytes
コンパイル時間 11,162 ms
コンパイル使用メモリ 209,752 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 04:38:08
合計ジャッジ時間 12,264 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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++
                }
        }
        ans := 0.0
        x := math.Min(G, C2)
        G -= x
        C2 -= x

        ans += x * 3

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

        ans += x * 3

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

        ans += x * 3

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

        ans += x

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

        ans += x

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

        ans += x

        fmt.Println(int(ans))
}
0