結果
| 問題 | No.9 モンスターのレベル上げ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-10-11 03:33:24 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 980 ms / 5,000 ms |
| コード長 | 1,976 bytes |
| コンパイル時間 | 4,159 ms |
| コンパイル使用メモリ | 84,196 KB |
| 実行使用メモリ | 61,000 KB |
| 最終ジャッジ日時 | 2024-06-23 21:58:59 |
| 合計ジャッジ時間 | 16,934 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
import java.util.Date;
import java.util.PriorityQueue;
import java.util.Scanner;
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;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
N = scanner.nextInt();
int[] party = new int[N + 1];
int[] enemy = new int[N + 1];
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");
}
}