結果

問題 No.161 制限ジャンケン
ユーザー hogekihogeki
提出日時 2016-08-11 22:34:36
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 58 ms / 5,000 ms
コード長 913 bytes
コンパイル時間 2,507 ms
コンパイル使用メモリ 102,440 KB
実行使用メモリ 22,768 KB
最終ジャッジ日時 2023-08-20 04:52:01
合計ジャッジ時間 4,140 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,836 KB
testcase_01 AC 57 ms
20,840 KB
testcase_02 AC 56 ms
20,704 KB
testcase_03 AC 57 ms
20,712 KB
testcase_04 AC 57 ms
20,844 KB
testcase_05 AC 56 ms
20,720 KB
testcase_06 AC 56 ms
18,616 KB
testcase_07 AC 55 ms
18,792 KB
testcase_08 AC 56 ms
20,788 KB
testcase_09 AC 58 ms
22,768 KB
testcase_10 AC 57 ms
18,724 KB
testcase_11 AC 58 ms
18,656 KB
testcase_12 AC 57 ms
20,732 KB
testcase_13 AC 57 ms
20,688 KB
testcase_14 AC 58 ms
18,672 KB
testcase_15 AC 58 ms
20,724 KB
testcase_16 AC 57 ms
20,672 KB
testcase_17 AC 57 ms
20,684 KB
testcase_18 AC 58 ms
20,736 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 Jyanken
{
	static void Main(String[] args)
	{
		int G, C, P;
		String S;
		int eg=0, ec=0, ep=0;
		String[] vals;

		vals = Console.ReadLine().Split(' ');
		G = int.Parse(vals[0]);
		C = int.Parse(vals[1]);
		P = int.Parse(vals[2]);
		S = Console.ReadLine();
		for(int i=0; i<S.Length; i++)
		{
			if(S[i] == 'G')
				eg++;
			else if(S[i] == 'C')
				ec++;
			else if(S[i] == 'P')
				ep++;
		}

		int score = 0;
		if(G < ec)
		{
			score += 3 * G;
			ec -= G;
			G = 0;
		}
		else
		{
			score += 3 * ec;
			G -= ec;
			ec = 0;
		}
		if(C < ep)
		{
			score += 3 * C;
			ep -= C;
			C = 0;
		}
		else
		{
			score += 3 * ep;
			C -= ep;
			ep = 0;
		}
		if(P < eg)
		{
			score += 3 * P;
			eg -= P;
			P = 0;
		}
		else
		{
			score += 3 * eg;
			P -= eg;
			eg = 0;
		}
		score += Math.Min(G, eg);
		score += Math.Min(C, ec);
		score += Math.Min(P, ep);
		Console.WriteLine(score);
	}

}
0