結果
| 問題 | No.9 モンスターのレベル上げ |
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-04-11 20:48:55 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,517 bytes |
| コンパイル時間 | 3,703 ms |
| コンパイル使用メモリ | 79,052 KB |
| 実行使用メモリ | 57,764 KB |
| 最終ジャッジ日時 | 2024-07-18 09:06:37 |
| 合計ジャッジ時間 | 8,635 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 WA * 12 |
ソースコード
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;
}
}
mban