結果

問題 No.9 モンスターのレベル上げ
ユーザー バカらっくバカらっく
提出日時 2017-06-26 03:32:07
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,774 bytes
コンパイル時間 1,066 ms
コンパイル使用メモリ 115,088 KB
実行使用メモリ 55,268 KB
最終ジャッジ日時 2024-04-15 00:34:41
合計ジャッジ時間 25,168 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
29,176 KB
testcase_01 AC 43 ms
25,400 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 43 ms
26,876 KB
testcase_11 AC 3,007 ms
52,696 KB
testcase_12 TLE -
testcase_13 AC 1,318 ms
53,620 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int monsterCount = int.Parse(Reader.ReadLine());
        int[] mikataArr = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int[] tekiArr = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int max = int.MaxValue;
        for (int i = 0; i < monsterCount; i++) {
            SortedDictionary<Monster, bool> mikata = new SortedDictionary<Monster, bool>();
            mikataArr.ToList().ForEach(a=>mikata.Add(new Monster(mikata.Count, a), true));
            List<int> tekiList = new List<int>(tekiArr.Skip(i));
            tekiList.AddRange(tekiArr.Take(i));
            int subMax = 0;
            bool mustBreak = false;
            for (int j = 0; j < monsterCount; j++) {
                Monster m = mikata.First().Key;
                mikata.Remove(m);
                m.Level += tekiList[i] / 2;
                m.BattleCount++;
                subMax = Math.Max(subMax, m.BattleCount);
				mikata.Add(m, true);
				if(subMax >= max) {
                    mustBreak = true;
                    break;
                }
            }
            if(mustBreak) {
                continue;
            }
            max = Math.Min(max, subMax);
        }
        Console.WriteLine(max);
    
    }


    private class Monster : IComparable, IEquatable<Monster>
    {
        public int Level;
        public int BattleCount;
        public int ID;
        public int CompareTo(object obj)
        {
            Monster mns = (Monster)obj;
            if (this.Level == mns.Level)
            {
                if(this.BattleCount == mns.BattleCount) {
                    return this.ID.CompareTo(mns.ID);
                }
                return this.BattleCount.CompareTo(mns.BattleCount);
            }
            return this.Level.CompareTo(mns.Level);
        }
        public Monster(int id, int level)
        {
            this.Level = level;
            this.BattleCount = 0;
            this.ID = id;
        }
        public bool Equals(Monster obj) {
            return obj.ID == this.ID;
        }
    
    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"




5
6 1 5 9 2
7 7 9 4 4




";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}
0