結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
nuwasogi
|
| 提出日時 | 2015-11-22 18:51:57 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 5,000 ms |
| コード長 | 2,120 bytes |
| コンパイル時間 | 865 ms |
| コンパイル使用メモリ | 108,032 KB |
| 実行使用メモリ | 19,328 KB |
| 最終ジャッジ日時 | 2024-11-30 04:47:01 |
| 合計ジャッジ時間 | 2,070 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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.Linq;
namespace Seigen_Janken
{
class Program
{
static void Main(string[] args)
{
Sol sol = new Sol();
sol.Solve();
}
}
class Sol
{
public void Solve()
{
int GN = Math.Min(G, eC);
int CN = Math.Min(C, eP);
int PN = Math.Min(P, eG);
G -= GN; eC -= GN;
C -= CN; eP -= CN;
P -= PN; eG -= PN;
int GDraw = Math.Min(G, eG);
int CDraw = Math.Min(C, eC);
int PDraw = Math.Min(P, eP);
int aiko = GDraw + CDraw + PDraw;
int ans = 3 * (GN + CN + PN) + aiko;
Console.WriteLine(ans);
}
int G, C, P;
string S;
int eG, eC, eP;
public Sol()
{
int[] t = ria();
G = t[0];
C = t[1];
P = t[2];
S = rs();
eG = CountChar(S, 'G');
eC = CountChar(S, 'C');
eP = CountChar(S, 'P');
}
// 文字列s中に含まれるcの数を返す
static int CountChar(string s, char c)
{
return s.Length - s.Replace(c.ToString(), "").Length;
}
public override string ToString()
{
return (string.Format("G:{0}, C:{1}, P{2}\n", G, C, P) + S + string.Format("\neG:{0}, eC:{1}, eP{2}", eG, eC, eP));
}
static String rs() { return Console.ReadLine(); }
static int ri() { return int.Parse(Console.ReadLine()); }
static long rl() { return long.Parse(Console.ReadLine()); }
static double rd() { return double.Parse(Console.ReadLine()); }
static String[] rsa() { return Console.ReadLine().Split(' '); }
static int[] ria() { return Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray(); }
static long[] rla() { return Console.ReadLine().Split(' ').Select(e => long.Parse(e)).ToArray(); }
static double[] rda() { return Console.ReadLine().Split(' ').Select(e => double.Parse(e)).ToArray(); }
}
}
nuwasogi