結果
| 問題 | No.9 モンスターのレベル上げ |
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-04-11 20:55:22 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 680 ms / 5,000 ms |
| コード長 | 1,590 bytes |
| コンパイル時間 | 3,612 ms |
| コンパイル使用メモリ | 78,896 KB |
| 実行使用メモリ | 48,116 KB |
| 最終ジャッジ日時 | 2024-06-23 23:56:51 |
| 合計ジャッジ時間 | 11,262 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
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 mon2 = new Mon(mon.level+b[index]/2,mon.battle+1);
result = Math.max(mon2.battle, result);
if(anser<=result)return;
copyPq.add(mon2);
}
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;
}
public Mon (int l,int b) {
level = l;
battle = b;
}
}
mban