結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー GinFizz1185GinFizz1185
提出日時 2020-02-10 09:23:37
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 3,945 bytes
コンパイル時間 1,951 ms
コンパイル使用メモリ 109,528 KB
実行使用メモリ 31,604 KB
最終ジャッジ日時 2024-04-08 12:47:55
合計ジャッジ時間 7,655 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
31,604 KB
testcase_01 AC 44 ms
24,672 KB
testcase_02 AC 32 ms
24,544 KB
testcase_03 AC 46 ms
24,532 KB
testcase_04 AC 46 ms
24,672 KB
testcase_05 AC 33 ms
24,544 KB
testcase_06 AC 76 ms
24,672 KB
testcase_07 AC 71 ms
24,672 KB
testcase_08 AC 122 ms
24,800 KB
testcase_09 AC 87 ms
24,672 KB
testcase_10 AC 101 ms
24,672 KB
testcase_11 AC 106 ms
24,800 KB
testcase_12 AC 26 ms
24,160 KB
testcase_13 AC 26 ms
24,160 KB
testcase_14 AC 26 ms
24,160 KB
testcase_15 AC 28 ms
24,160 KB
testcase_16 AC 26 ms
24,160 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace yukicode
{
    class No935
    {
        static void Main(string[] args)
        {
            int targetNum = 0;
            int attackNum = 0;
            int retOne = 0;
            int retStart = 0;
            int retEnd = 0;
            int output = 0;
            int power = 0;
            string input;
            string sort;

            input = Console.ReadLine();
            targetNum = int.Parse(input);

            sort = Console.ReadLine();

            input = Console.ReadLine();
            string[] str1 = input.Split(" ");
            int[] hp = new int[targetNum];
            for(int i=0; i < targetNum; i++)
            {
                hp[i] = int.Parse(str1[i]);
            }

            input = Console.ReadLine();
            attackNum = int.Parse(input);

            input = Console.ReadLine();
            string[] str2 = input.Split(" ");
            for (int i = 0; i < attackNum; i++)
            {
                power = int.Parse(str2[i]);

                retOne = AttackOne(sort, hp, power);

                if(1 == retOne)
                {
                    retStart = AttackStart(sort, hp, power);

                    retEnd = AttackEnd(sort, hp, power);

                    if(retStart >= retEnd)
                    {
                        output = retStart;
                    }
                    else
                    {
                        output = retEnd;
                    }
                }
                else
                {
                    output = retOne;
                }
                Console.WriteLine(output);
            }

            return;
        }

        static private int AttackOne(string sort, int[] hp, int power)
        {
            int ret = 0;
            for(int i = 0; i < hp.Length; i++)
            {
                if('E' == sort[i])
                {
                    if(hp[i] <= power)
                    {
                        ret = 1;
                        break;
                    }
                }
            }

            return ret;
        }

        static private int AttackStart(string sort, int[] hp, int power)
        {
            int ret = 0;
            int tempMax = 0;
            int tempPower = 0;

            for(int i = 0; i < hp.Length; i++)
            {
                tempMax = 0;
                tempPower = power;
                for (int j = i; j < hp.Length; j++)
                {
                    if (hp[j] <= tempPower)
                    {
                        tempPower = tempPower - hp[j];
                        if ('E' == sort[j])
                        {
                            tempMax++;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                if(ret < tempMax)
                {
                    ret = tempMax;
                }
            }

            return ret;
        }

        static private int AttackEnd(string sort, int[] hp, int power)
        {
            int ret = 0;
            int tempMax = 0;
            int tempPower = 0;

            for (int i = hp.Length -1; i >= 0; i--)
            {
                tempMax = 0;
                tempPower = power;
                for (int j = 0; j >= 0; j--)
                {
                    if (hp[i] <= tempPower)
                    {
                        tempPower = tempPower - hp[i];
                        if ('E' == sort[i])
                        {
                            tempMax++;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                if (ret < tempMax)
                {
                    ret = tempMax;
                }
            }

            return ret;
        }
    }
}
0