結果

問題 No.9 モンスターのレベル上げ
ユーザー mastersatoshimastersatoshi
提出日時 2015-08-03 13:10:04
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 2,789 bytes
コンパイル時間 2,500 ms
コンパイル使用メモリ 75,508 KB
実行使用メモリ 64,656 KB
最終ジャッジ日時 2023-09-25 00:52:48
合計ジャッジ時間 8,909 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,420 KB
testcase_01 AC 43 ms
49,388 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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int N = Integer.parseInt(br.readLine());

        int[] A = convert(br.readLine().split(" "));
        int[] B = convert(br.readLine().split(" "));

        ArrayList<int[]> team = new ArrayList();

        for (int i = 0; i < N; i++) {
            team.add(new int[]{A[i], 0});
        }

        team.sort(new CustomComparator());

        int maxMini = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                int enemy = i + j;
                if (enemy >= N) {
                    enemy = enemy - N;
                }

                int[] tmp = team.get(0);

                tmp[0] = tmp[0] + (B[enemy] / 2);

                tmp[1] = tmp[1] + 1;

                team.set(0, tmp);

                team.sort(new CustomComparator());
            }

            team.sort(new LevelSort());

            if (maxMini > team.get(0)[1]) {
                maxMini = team.get(0)[1];
            }
        }

        System.out.println(maxMini);
    }

    private static int[] convert(String[] source) {
        int[] ret = new int[source.length];
        for (int i = 0; i < source.length; i++) {
            ret[i] = Integer.parseInt(source[i]);
        }
        return ret;
    }

    static class CustomComparator implements Comparator<int[]> {

        //比較メソッド(データクラスを比較して-1, 0, 1を返すように記述する)
        public int compare(int[] a, int[] b) {
            int no1 = a[0];
            int no2 = b[0];
            int no3 = a[1];
            int no4 = b[1];

            //こうすると社員番号の昇順でソートされる
            if (no1 > no2) {
                return 1;

            } else if (no1 == no2) {
                if (no3 > no4) {
                    return 1;

                } else if (no3 == no4) {
                    return 0;

                } else {
                    return -1;

                }

            } else {
                return -1;

            }
        }
    }

    static class LevelSort implements Comparator<int[]> {

        //比較メソッド(データクラスを比較して-1, 0, 1を返すように記述する)
        public int compare(int[] a, int[] b) {
            int no1 = a[1];
            int no2 = b[1];

            //こうすると社員番号の昇順でソートされる
            if (no1 < no2) {
                return 1;

            } else if (no1 == no2) {
                return 0;

            } else {
                return -1;

            }
        }
    }
}
0