結果

問題 No.161 制限ジャンケン
ユーザー syoken_desukasyoken_desuka
提出日時 2015-03-05 23:33:04
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 54 ms / 5,000 ms
コード長 4,972 bytes
コンパイル時間 5,565 ms
コンパイル使用メモリ 107,036 KB
実行使用メモリ 22,820 KB
最終ジャッジ日時 2023-08-20 04:21:07
合計ジャッジ時間 7,448 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
20,656 KB
testcase_01 AC 54 ms
20,768 KB
testcase_02 AC 54 ms
20,740 KB
testcase_03 AC 52 ms
20,780 KB
testcase_04 AC 52 ms
20,656 KB
testcase_05 AC 54 ms
22,676 KB
testcase_06 AC 53 ms
20,724 KB
testcase_07 AC 53 ms
20,732 KB
testcase_08 AC 52 ms
22,696 KB
testcase_09 AC 53 ms
20,680 KB
testcase_10 AC 53 ms
22,820 KB
testcase_11 AC 54 ms
20,692 KB
testcase_12 AC 53 ms
18,656 KB
testcase_13 AC 54 ms
20,680 KB
testcase_14 AC 53 ms
22,792 KB
testcase_15 AC 52 ms
20,828 KB
testcase_16 AC 51 ms
20,700 KB
testcase_17 AC 53 ms
22,700 KB
testcase_18 AC 53 ms
20,708 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

#region ZIPPER
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Numerics;
using sc = Scanner;
class Program
{
    static void Main(string[] args)
    {
        Solver solver = new Solver();
        solver.Solve();
#if DEBUG
        System.Console.WriteLine("続行するには何かキーを押してください...");
        System.Console.ReadKey();
#endif

    }
}
/// <summary>
/// Java風のスキャナー,自作(某最速の人を参考)
/// </summary>
public static class Scanner
{
    public static string NextString()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return tmp;
    }
    public static int NextInt()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return int.Parse(tmp);
    }
    public static long NextLong()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return long.Parse(tmp);
    }
    public static double NextDouble()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return double.Parse(tmp);
    }

    public static string[] NextStrArray()
    {
        return Console.ReadLine().Split(' ');
    }
    public static int[] NextIntArray()
    {

        string[] s = NextStrArray();
        int[] a = new int[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = int.Parse(s[i]);
        }
        return a;
    }
    public static long[] NextLongArray()
    {
        string[] s = NextStrArray();
        long[] a = new long[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = long.Parse(s[i]);
        }
        return a;
    }
    public static double[] NextDoubleArray()
    {
        string[] s = NextStrArray();
        double[] a = new double[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = double.Parse(s[i]);
        }
        return a;
    }
}
#endregion ZIPPER

public class Solver
{
#region IGNORE_ME
    public Solver()
    {
        //こんすとらくたん きにしなくてよろしい
    }
#endregion IGNORE_ME

#region FIELD

#endregion FIELD

    public void Solve()
    {
        int g = sc.NextInt();
        int t = sc.NextInt();
        int p = sc.NextInt();
        string s = Console.ReadLine();
        int answer = 0;
        string horyuu = "";
        //kateru yatuha donyokuni katteoku
        for (int i = 0; i < s.Length; i++)
        {
            if (g>0 && s[i] == 'C')
            { 
                g--;
                answer += 3;
            }
            else if(t > 0 && s[i]== 'P')
            { 
                t--;
                answer += 3;
            }
            else if(p > 0 && s[i] == 'G')
            {
                p--;
                answer+= 3;
            }
            else //aiko nerai
            {
                horyuu += s[i]; 
            }
        }
        for (int i = 0; i < horyuu.Length; i++)
        {
             if (t>0 && horyuu[i] == 'C')
            { 
                t--;
                answer++;
            }
            else if(p > 0 && horyuu[i]== 'P')
            { 
                p--;
                answer++;
            }
            else if(g > 0 && horyuu[i] == 'G')
            {
                g--;
                answer++;
            }
            else //owata
            {
            }
        }
        Console.WriteLine(answer);

#if DEBUG
        Console.WriteLine("");//local check
#endif
    }

}
0