結果
| 問題 |
No.9 モンスターのレベル上げ
|
| コンテスト | |
| ユーザー |
mastersatoshi
|
| 提出日時 | 2015-08-03 14:11:30 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,240 bytes |
| コンパイル時間 | 2,357 ms |
| コンパイル使用メモリ | 78,600 KB |
| 実行使用メモリ | 55,136 KB |
| 最終ジャッジ日時 | 2024-07-18 01:06:53 |
| 合計ジャッジ時間 | 10,060 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 WA * 12 |
ソースコード
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());
String[] A = br.readLine().split(" ");
String[] B = br.readLine().split(" ");
PriorityQueue<CustomComparator> pq = new PriorityQueue();
for (int i = 0; i < N; i++) {
int[] a = new int[]{Integer.parseInt(A[i]), 0};
CustomComparator aa = new CustomComparator(a);
pq.add(aa);
}
int maxMini = Integer.MAX_VALUE;
for (int i = 0; i < N; i++) {
int tmpMax = 0;
for (int j = 0; j < N; j++) {
int enemy = i + j;
if (enemy >= N) {
enemy = enemy - N;
}
CustomComparator tmp = pq.poll();
tmp.a[0] = tmp.a[0] + (Integer.parseInt(B[enemy]) / 2);
tmp.a[1] = tmp.a[1] + 1;
if (tmpMax < tmp.a[1]) {
tmpMax = tmp.a[1];
}
pq.add(tmp);
}
if (maxMini > tmpMax) {
maxMini = tmpMax;
}
}
System.out.println(maxMini);
}
static class CustomComparator implements Comparable<CustomComparator> {
int[] a;
public CustomComparator(int[] a) {
this.a = a;
}
//比較メソッド(データクラスを比較して-1, 0, 1を返すように記述する)
public int compareTo(CustomComparator b) {
int no1 = a[0];
int no2 = b.a[0];
int no3 = a[1];
int no4 = b.a[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;
}
}
}
}
mastersatoshi