結果

問題 No.9 モンスターのレベル上げ
ユーザー バカらっくバカらっく
提出日時 2017-06-26 21:38:22
言語 C#
(csc 3.9.0)
結果
AC  
実行時間 4,710 ms / 5,000 ms
コード長 3,329 bytes
コンパイル時間 2,262 ms
使用メモリ 38,964 KB
最終ジャッジ日時 2023-01-21 16:46:38
合計ジャッジ時間 28,811 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 66 ms
17,272 KB
testcase_01 AC 66 ms
17,172 KB
testcase_02 AC 2,514 ms
38,504 KB
testcase_03 AC 1,487 ms
37,112 KB
testcase_04 AC 1,085 ms
30,468 KB
testcase_05 AC 758 ms
26,764 KB
testcase_06 AC 302 ms
21,976 KB
testcase_07 AC 72 ms
18,264 KB
testcase_08 AC 346 ms
22,644 KB
testcase_09 AC 2,324 ms
37,992 KB
testcase_10 AC 65 ms
17,204 KB
testcase_11 AC 2,718 ms
38,316 KB
testcase_12 AC 4,710 ms
38,964 KB
testcase_13 AC 1,212 ms
34,908 KB
testcase_14 AC 2,284 ms
37,268 KB
testcase_15 AC 2,296 ms
37,152 KB
testcase_16 AC 111 ms
21,456 KB
testcase_17 AC 1,540 ms
37,464 KB
testcase_18 AC 1,265 ms
33,624 KB
testcase_19 AC 99 ms
21,416 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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));
            int subMax = 0;
            bool mustBreak = false;
            for (int j = 0; j < monsterCount; j++) {
                Monster m = mikata.First().Key;
                mikata.Remove(m);
                m.Level += tekiArr[(i+j)%monsterCount] / 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 = @"




69
3253 3369 660 1949 4617 3586 3561 3382 7928 4932 2034 599 7713 1984 4040 5308 7972 6853 6802 5811 2226 4349 1997 4202 195 6608 1785 823 1084 2947 6118 4671 5526 4139 7016 3932 6534 1867 935 4629 4405 67 4014 1322 3329 4949 4990 2086 4517 897 6712 6512 4017 2083 7666 2190 4897 6482 7590 2197 7370 2163 6238 5317 6435 5041 5513 2275 4978
3003 1579 6252 1970 1595 2763 3275 5453 2496 6143 4733 589 1886 6384 3295 1223 3714 2426 5626 149 1848 3978 6608 6489 2454 106 2197 2982 4055 1239 7266 1774 329 6684 1063 7593 5659 7697 6475 815 1606 7363 35 5780 3853 3072 7709 7822 1902 7030 6723 5812 7640 3297 6286 3634 123 7996 7811 5854 4299 885 310 1943 3064 7146 897 3778 6973




";
	}

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