結果
| 問題 |
No.9 モンスターのレベル上げ
|
| コンテスト | |
| ユーザー |
mastersatoshi
|
| 提出日時 | 2015-08-03 13:10:04 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,789 bytes |
| コンパイル時間 | 2,521 ms |
| コンパイル使用メモリ | 79,284 KB |
| 実行使用メモリ | 66,716 KB |
| 最終ジャッジ日時 | 2024-07-18 01:06:33 |
| 合計ジャッジ時間 | 9,280 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 TLE * 1 -- * 17 |
ソースコード
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());
int[] A = convert(br.readLine().split(" "));
int[] B = convert(br.readLine().split(" "));
ArrayList<int[]> team = new ArrayList();
for (int i = 0; i < N; i++) {
team.add(new int[]{A[i], 0});
}
team.sort(new CustomComparator());
int maxMini = Integer.MAX_VALUE;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
int enemy = i + j;
if (enemy >= N) {
enemy = enemy - N;
}
int[] tmp = team.get(0);
tmp[0] = tmp[0] + (B[enemy] / 2);
tmp[1] = tmp[1] + 1;
team.set(0, tmp);
team.sort(new CustomComparator());
}
team.sort(new LevelSort());
if (maxMini > team.get(0)[1]) {
maxMini = team.get(0)[1];
}
}
System.out.println(maxMini);
}
private static int[] convert(String[] source) {
int[] ret = new int[source.length];
for (int i = 0; i < source.length; i++) {
ret[i] = Integer.parseInt(source[i]);
}
return ret;
}
static class CustomComparator implements Comparator<int[]> {
//比較メソッド(データクラスを比較して-1, 0, 1を返すように記述する)
public int compare(int[] a, int[] b) {
int no1 = a[0];
int no2 = b[0];
int no3 = a[1];
int no4 = b[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;
}
}
}
static class LevelSort implements Comparator<int[]> {
//比較メソッド(データクラスを比較して-1, 0, 1を返すように記述する)
public int compare(int[] a, int[] b) {
int no1 = a[1];
int no2 = b[1];
//こうすると社員番号の昇順でソートされる
if (no1 < no2) {
return 1;
} else if (no1 == no2) {
return 0;
} else {
return -1;
}
}
}
}
mastersatoshi