結果

問題 No.9 モンスターのレベル上げ
ユーザー yuki2006yuki2006
提出日時 2014-10-11 03:29:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,063 ms / 5,000 ms
コード長 1,932 bytes
コンパイル時間 4,814 ms
コンパイル使用メモリ 84,080 KB
実行使用メモリ 63,200 KB
最終ジャッジ日時 2023-09-06 03:06:07
合計ジャッジ時間 18,320 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 148 ms
55,768 KB
testcase_01 AC 145 ms
56,184 KB
testcase_02 AC 1,063 ms
62,700 KB
testcase_03 AC 869 ms
62,220 KB
testcase_04 AC 657 ms
62,500 KB
testcase_05 AC 585 ms
62,440 KB
testcase_06 AC 386 ms
61,796 KB
testcase_07 AC 188 ms
56,396 KB
testcase_08 AC 424 ms
63,024 KB
testcase_09 AC 1,021 ms
62,752 KB
testcase_10 AC 148 ms
55,948 KB
testcase_11 AC 999 ms
63,200 KB
testcase_12 AC 1,000 ms
62,632 KB
testcase_13 AC 813 ms
61,224 KB
testcase_14 AC 1,021 ms
62,892 KB
testcase_15 AC 1,023 ms
62,988 KB
testcase_16 AC 249 ms
58,492 KB
testcase_17 AC 751 ms
63,100 KB
testcase_18 AC 714 ms
62,768 KB
testcase_19 AC 222 ms
58,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Yuki009 {


    static class Tuple implements Comparable<Tuple> {
        int level;
        int count;

        Tuple(int level, int count) {
            this.level = level;
            this.count = count;
        }

        @Override
        public int compareTo(Tuple o) {
            int value = Integer.compare(level, o.level);
            if (value == 0) {
                return Integer.compare(count, o.count);
            }
            return value;
        }
    }

    static int N = 1500;
    static int K = 10000;


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        N = scanner.nextInt();
        int[] party = new int[N];
        int[] enemy = new int[N];
        long exec_time = new Date().getTime();

        for (int i = 0; i < N; i++) {
            party[i] = scanner.nextInt();
        }
        for (int i = 0; i < N; i++) {
            enemy[i] = scanner.nextInt();
        }
        int min = N;

        for (int i = 0; i < N; i++) {
            PriorityQueue<Tuple> queue = new PriorityQueue<Tuple>(N);
            for (int k = 0; k < N; k++) {
                queue.add(new Tuple(party[k], 0));
            }

            for (int j = 0; j < N; j++) {
                Tuple t = queue.poll();
                t.level += enemy[(i + j) % N] / 2;
                t.count++;
                queue.add(t);
            }
            //最後に一番試合数が要素を見つけるので配列に起こす。
            Tuple[] tuples = queue.toArray(new Tuple[0]);
            int max = 0;
            for (Tuple t : tuples) {
                max = Math.max(max, t.count);
            }
            min = Math.min(min, max);
        }
        System.out.println(min);
        System.err.println(new Date().getTime() - exec_time + "ms");


    }


}
0