結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2016-12-31 08:52:46 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 29 ms / 5,000 ms |
コード長 | 1,133 bytes |
コンパイル時間 | 2,405 ms |
コンパイル使用メモリ | 109,132 KB |
実行使用メモリ | 26,388 KB |
最終ジャッジ日時 | 2024-11-30 05:07:26 |
合計ジャッジ時間 | 3,282 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);}}