結果
| 問題 |
No.9 モンスターのレベル上げ
|
| ユーザー |
バカらっく
|
| 提出日時 | 2017-06-26 03:32:07 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,774 bytes |
| コンパイル時間 | 854 ms |
| コンパイル使用メモリ | 115,728 KB |
| 実行使用メモリ | 56,476 KB |
| 最終ジャッジ日時 | 2024-10-04 07:03:02 |
| 合計ジャッジ時間 | 20,733 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 14 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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();
}
}
バカらっく