結果

問題 No.161 制限ジャンケン
ユーザー hogeki
提出日時 2016-08-11 22:34:36
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 24 ms / 5,000 ms
コード長 913 bytes
コンパイル時間 843 ms
コンパイル使用メモリ 113,304 KB
実行使用メモリ 17,920 KB
最終ジャッジ日時 2024-11-30 04:53:57
合計ジャッジ時間 1,765 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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.

ソースコード

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