結果

問題 No.9 モンスターのレベル上げ
ユーザー 14番14番
提出日時 2016-03-30 14:55:24
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 2,905 bytes
コンパイル時間 967 ms
コンパイル使用メモリ 115,936 KB
実行使用メモリ 29,996 KB
最終ジャッジ日時 2024-04-10 06:30:08
合計ジャッジ時間 7,576 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,988 KB
testcase_01 AC 28 ms
26,120 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.Collections.Generic;

public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        int cnt = int.Parse(Reader.ReadLine());
        
        int[] inpt = Reader.GetInt();
        for(int i=0; i<inpt.Length; i++) {
            this.MikataList.Add(new Mikata(inpt[i]));
        }
        inpt = Reader.GetInt();
        List<int> tekiOriginal = new List<int>();
        tekiOriginal.AddRange(inpt);
        
        int ans = int.MaxValue;
                
        for(int i=0; i<inpt.Length; i++) {
            int[] tekiArray = new int[tekiOriginal.Count];
            tekiOriginal.CopyTo(i, tekiArray, 0, tekiOriginal.Count - i);
            if(i > 0) {
                tekiOriginal.CopyTo(0, tekiArray, tekiOriginal.Count - i, i);
            }
            int maxCount = 0;
            for(int j=0; j<tekiArray.Length; j++) {
                this.MikataList.Sort((a,b)=>{
                    if(a.Level < b.Level) {
                        return -1;
                    } else if(a.Level > b.Level)
                    {
                         return 1;
                    } else if(a.Count < b.Count)
                    {
                         return - 1;
                    } else if(a.Count > b.Count)
                    {
                        return 1;
                    }
                    return 0;
                });
                this.MikataList[0].Level += (tekiArray[j] / 2);
                this.MikataList[0].Count++;
                maxCount = Math.Max(maxCount, this.MikataList[0].Count);
            }
            ans = Math.Min(ans, maxCount);
        }
        Console.WriteLine(ans);

    }

    private List<Mikata> MikataList = new List<Mikata>();
    
    public class Mikata {
        public int Level = 0;
        public int Count = 0;
        public Mikata(int defaultLevel) {
            this.Level = defaultLevel;
        }
    }

    public class Reader {
        private static String InitText = @"


5
6 1 5 9 2
7 7 9 4 4



        ";
        
        private static System.IO.StringReader sr = null;
        
        public static bool IsDebug = true;
        
        public static string ReadLine() {
            if(IsDebug) {
                if(sr == null) {
                    sr = new System.IO.StringReader(InitText.Trim());
                }
                return sr.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
        public static int[] GetInt(char delimiter = ' ') {
            string[] inpt = ReadLine().Split(delimiter);
            int[] ret = new int[inpt.Length];
            for(int i=0; i<inpt.Length; i++) {
                ret[i] = int.Parse(inpt[i]);
            }
            return ret;
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0