結果

問題 No.9 モンスターのレベル上げ
ユーザー mbanmban
提出日時 2017-04-11 20:48:55
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,517 bytes
コンパイル時間 3,863 ms
コンパイル使用メモリ 80,124 KB
実行使用メモリ 61,608 KB
最終ジャッジ日時 2023-09-25 11:17:02
合計ジャッジ時間 9,723 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,728 KB
testcase_01 AC 124 ms
55,712 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 123 ms
55,468 KB
testcase_11 AC 220 ms
59,112 KB
testcase_12 AC 222 ms
59,340 KB
testcase_13 AC 217 ms
59,392 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 204 ms
60,104 KB
testcase_18 AC 207 ms
59,020 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Program {
	public static void main(String[] args) {
		new Magatro().solve();
	}
}

class Magatro {
	private int n;
	private int[] a, b;
	private PriorityQueue<Mon> priorityQueue;
	private int anser = Integer.MAX_VALUE;

	private void scan() {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		a = new int[n];
		b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextInt();
		}
		for (int i = 0; i < n; i++) {
			b[i] = scanner.nextInt();
		}
	}

	private void battle(int start) {
		int result = -1;
		PriorityQueue<Mon> copyPq = new PriorityQueue<Mon>(priorityQueue);
		for (int i = 0; i < n; i++) {
			int index = (i+start)%n;
			Mon mon = copyPq.poll();
			mon.battle++;
			result = Math.max(mon.battle, result);
			if(anser<=result)return;
			mon.level += b[index]/2;
			copyPq.add(mon);
		}
		anser = result;
	}

	public void solve() {
		scan();

		priorityQueue = new PriorityQueue<>(1, new MyComparator());
		for (int i : a) {
			priorityQueue.add(new Mon(i));
		}
		
		for(int i=0;i<n;i++){
			battle(i);
		}
		System.out.println(anser);
	}
}

class MyComparator implements Comparator<Mon> {
	public int compare(Mon a, Mon b) {
		if (a.level != b.level) {
			return Integer.compare(a.level, b.level);
		} else {
			return Integer.compare(a.battle, b.battle);
		}
	}
}

class Mon {
	public int level;
	public int battle;

	public Mon(int l) {
		level = l;
		battle = 0;
	}
}
0