結果

問題 No.9 モンスターのレベル上げ
ユーザー HimatsubushinHimatsubushin
提出日時 2021-01-17 09:41:07
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,912 bytes
コンパイル時間 5,817 ms
コンパイル使用メモリ 107,540 KB
実行使用メモリ 21,592 KB
最終ジャッジ日時 2023-08-19 13:26:44
合計ジャッジ時間 14,241 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
21,576 KB
testcase_01 AC 63 ms
21,592 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;

namespace No
{
    class MainClass
    {
        static int n;
        static int[][] a;
        static int[] b;

        public static void Main(string[] args)
        {
            n = int.Parse(Console.ReadLine());
            a = new int[2][];
            a[0] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            b = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int max_battle_number = 0;

            for (int start = 0; start < n; start++)
            {
                int[] battle_number = new int[n];
                int pos = start, count = 0;

                a[1] = new int[n];

                while (true)
                {
                    int battle_index = checkBattler();
                    a[0][battle_index] += b[pos] / 2;
                    a[1][battle_index]++;

                    pos++;
                    if (pos >= n)
                        pos = 0;

                    count++;
                    if (count == n)
                        break;
                }

                if (max_battle_number <= a[1].Max())
                    max_battle_number = a[1].Max();
            }

            Console.WriteLine(max_battle_number);
        }

        private static int checkBattler()
        {
            int min_level = a[0].Min();
            int max_battle = a[1].Max();
            int target_index = 0;

            foreach(var data in a[0].Select((value, index) => new {Value = value, Index = index}))
            {
                if (data.Value == min_level)
                {
                    if (a[1][data.Index] <= max_battle)
                    {
                        max_battle = a[1][data.Index];
                        target_index = data.Index;
                    }
                }
            }

            return target_index;
        }
    }
}
0