結果

問題 No.9 モンスターのレベル上げ
ユーザー バカらっくバカらっく
提出日時 2017-06-26 21:38:22
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 4,885 ms / 5,000 ms
コード長 3,329 bytes
コンパイル時間 2,468 ms
コンパイル使用メモリ 109,356 KB
実行使用メモリ 46,100 KB
最終ジャッジ日時 2023-09-06 05:30:36
合計ジャッジ時間 30,066 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
25,348 KB
testcase_01 AC 73 ms
23,204 KB
testcase_02 AC 2,600 ms
44,604 KB
testcase_03 AC 1,556 ms
45,204 KB
testcase_04 AC 1,129 ms
36,556 KB
testcase_05 AC 796 ms
32,728 KB
testcase_06 AC 307 ms
30,048 KB
testcase_07 AC 76 ms
23,208 KB
testcase_08 AC 355 ms
30,664 KB
testcase_09 AC 2,422 ms
46,100 KB
testcase_10 AC 70 ms
23,252 KB
testcase_11 AC 2,845 ms
44,300 KB
testcase_12 AC 4,885 ms
44,984 KB
testcase_13 AC 1,267 ms
42,996 KB
testcase_14 AC 2,382 ms
45,256 KB
testcase_15 AC 2,386 ms
43,148 KB
testcase_16 AC 114 ms
25,480 KB
testcase_17 AC 1,580 ms
43,548 KB
testcase_18 AC 1,322 ms
41,756 KB
testcase_19 AC 107 ms
27,572 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