結果

問題 No.161 制限ジャンケン
ユーザー しらゆきしらゆき
提出日時 2015-11-24 09:41:36
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 907 bytes
コンパイル時間 2,249 ms
コンパイル使用メモリ 104,260 KB
実行使用メモリ 22,836 KB
最終ジャッジ日時 2023-08-20 04:43:39
合計ジャッジ時間 4,505 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
20,784 KB
testcase_01 AC 59 ms
20,776 KB
testcase_02 AC 59 ms
22,836 KB
testcase_03 AC 60 ms
20,736 KB
testcase_04 AC 60 ms
22,728 KB
testcase_05 AC 64 ms
20,752 KB
testcase_06 AC 61 ms
22,736 KB
testcase_07 AC 59 ms
20,784 KB
testcase_08 AC 60 ms
22,820 KB
testcase_09 AC 58 ms
18,684 KB
testcase_10 AC 59 ms
20,748 KB
testcase_11 AC 61 ms
22,828 KB
testcase_12 AC 57 ms
20,892 KB
testcase_13 AC 56 ms
20,740 KB
testcase_14 AC 58 ms
22,828 KB
testcase_15 AC 57 ms
20,648 KB
testcase_16 AC 58 ms
20,732 KB
testcase_17 AC 57 ms
20,732 KB
testcase_18 AC 56 ms
20,680 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Program
{
    static void Main()
    {
        var tmp = Console.ReadLine().Split();
        int g = int.Parse(tmp[0]);
        int c = int.Parse(tmp[1]);
        int p = int.Parse(tmp[2]);
        var s = Console.ReadLine();

        int g2, c2, p2;
        g2 = c2 = p2 = 0;
        for(int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'G') g2++;
            else if (s[i] == 'C') c2++;
            else p2++;
        }

        int ans = 0;

        int gwin = Math.Min(g, c2);
        int cwin = Math.Min(c, p2);
        int pwin = Math.Min(p, g2);
        g -= gwin; c2 -= gwin;
        c -= cwin; p2 -= cwin;
        p -= pwin; g2 -= pwin;
        ans += (gwin + cwin + pwin) * 3;

        int gtie = Math.Min(g, g2);
        int ctie = Math.Min(c, c2);
        int ptie = Math.Min(p, p2);
        ans += gtie + ctie + ptie;

        Console.WriteLine(ans);
    }
}
0