結果

問題 No.161 制限ジャンケン
ユーザー mbanmban
提出日時 2016-12-31 08:52:46
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 65 ms / 5,000 ms
コード長 1,133 bytes
コンパイル時間 3,202 ms
コンパイル使用メモリ 104,912 KB
実行使用メモリ 22,800 KB
最終ジャッジ日時 2023-08-20 04:58:37
合計ジャッジ時間 5,513 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
22,660 KB
testcase_01 AC 61 ms
20,712 KB
testcase_02 AC 60 ms
22,652 KB
testcase_03 AC 65 ms
22,724 KB
testcase_04 AC 61 ms
20,796 KB
testcase_05 AC 60 ms
20,780 KB
testcase_06 AC 61 ms
20,752 KB
testcase_07 AC 60 ms
22,800 KB
testcase_08 AC 61 ms
22,736 KB
testcase_09 AC 60 ms
20,756 KB
testcase_10 AC 61 ms
22,756 KB
testcase_11 AC 61 ms
22,788 KB
testcase_12 AC 60 ms
20,800 KB
testcase_13 AC 61 ms
20,688 KB
testcase_14 AC 61 ms
20,680 KB
testcase_15 AC 60 ms
20,696 KB
testcase_16 AC 60 ms
20,684 KB
testcase_17 AC 61 ms
22,796 KB
testcase_18 AC 62 ms
22,720 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{
    static void Main()
    {
        int G, C, P;
        string[] s = Console.ReadLine().Split(' ');
        G = int.Parse(s[0]);
        C = int.Parse(s[1]);
        P = int.Parse(s[2]);
        string S = Console.ReadLine();
        Dictionary<char, int> cnt = new Dictionary<char, int>();
        cnt.Add('G', 0);
        cnt.Add('C', 0);
        cnt.Add('P', 0);
        for(int i = 0; i < S.Length; i++)
        {
            cnt[S[i]]++;
        }
        int ans = 0;
        int c = 0;
       int GG= Math.Min(G, cnt['C']);
        c += GG;
        G -= GG;
        cnt['C'] -= GG;
        GG = Math.Min(P, cnt['G']);
        c += GG;
        cnt['G'] -= GG;
        P -= GG;
        GG = Math.Min(C, cnt['P']);
        c += GG;
        cnt['P'] -= GG;
        C -= GG;
        ans += 3 * c;
        ans += Math.Min(G, cnt['G']) + Math.Min(C, cnt['C']) + Math.Min(P, cnt['P']);
        Console.WriteLine(ans);
    }
}

0