結果

問題 No.9 モンスターのレベル上げ
ユーザー 14番14番
提出日時 2016-03-30 15:56:31
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 3,668 bytes
コンパイル時間 1,075 ms
コンパイル使用メモリ 116,312 KB
実行使用メモリ 47,264 KB
最終ジャッジ日時 2024-04-10 06:33:11
合計ジャッジ時間 38,786 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
24,040 KB
testcase_01 AC 29 ms
24,172 KB
testcase_02 AC 4,510 ms
44,304 KB
testcase_03 AC 3,265 ms
44,580 KB
testcase_04 AC 1,482 ms
30,668 KB
testcase_05 AC 904 ms
33,184 KB
testcase_06 AC 272 ms
26,744 KB
testcase_07 AC 32 ms
24,240 KB
testcase_08 AC 378 ms
26,516 KB
testcase_09 AC 4,332 ms
44,720 KB
testcase_10 RE -
testcase_11 AC 2,787 ms
46,508 KB
testcase_12 AC 4,578 ms
46,512 KB
testcase_13 AC 1,932 ms
44,348 KB
testcase_14 AC 4,390 ms
46,524 KB
testcase_15 AC 3,865 ms
47,264 KB
testcase_16 AC 63 ms
24,936 KB
testcase_17 AC 2,219 ms
42,052 KB
testcase_18 AC 1,778 ms
40,972 KB
testcase_19 AC 48 ms
24,668 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.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++) {
            Mikata m = new Mikata();
            m.Count = 0;
            m.Level = inpt[i];
            this.MikataList.Add(m);
        }
        this.MikataList.Sort((a,b)=>{ return (a.Level < b.Level)?-1:((a.Level > b.Level)?1:0); });
        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];
            List<Mikata> tmpMikata = new List<Mikata>();
            tmpMikata.AddRange(this.MikataList);
            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++) {
                Mikata m = tmpMikata[0];
                tmpMikata.RemoveAt(0);
                m.Level += (tekiArray[j] / 2);
                m.Count++;
                maxCount = Math.Max(maxCount, m.Count);
                int idx = this.FindIndex(tmpMikata, m, 0, tmpMikata.Count - 1);
                tmpMikata.Insert(idx, m);
            }
            ans = Math.Min(ans, maxCount);
        }
        Console.WriteLine(ans);

    }
    
    
    private int FindIndex(List<Mikata> list, Mikata el, int startIdx, int endIdx) {
        if(Compair(el, list[startIdx]) <= 0) {
            return startIdx;
        }
        if(Compair(el, list[endIdx]) >= 0) {
            return endIdx + 1;
        }
        if(endIdx - startIdx <= 1) {
            return endIdx;
        }
        int mid = (startIdx + endIdx) / 2;
        int tmp = Compair(el, list[mid]);
        if(tmp < 0) {
            return this.FindIndex(list, el, startIdx, mid - 1);
        } else if(tmp > 0) {
            return this.FindIndex(list, el, mid, endIdx);
        }
        return mid;
    }
    
    private int Compair(Mikata a, Mikata b) {
        if(a.Level < b.Level) {
            return -1;
        }
        if(a.Level > b.Level) {
            return 1;
        }
        if(a.Count < b.Count) {
            return -1;
        }
        if(a.Count > b.Count) {
            return 1;
        }
        return 0;
    }

    private List<Mikata> MikataList = new List<Mikata>();
    
    public struct Mikata {
        public int Level;
        public int Count;
    }

    public class Reader {
        private static String InitText = @"






        ";
        
        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