結果
問題 | No.9 モンスターのレベル上げ |
ユーザー | mastersatoshi |
提出日時 | 2015-08-03 14:11:30 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,240 bytes |
コンパイル時間 | 2,037 ms |
コンパイル使用メモリ | 74,808 KB |
実行使用メモリ | 55,848 KB |
最終ジャッジ日時 | 2023-09-25 00:53:07 |
合計ジャッジ時間 | 10,245 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
49,600 KB |
testcase_01 | AC | 44 ms
49,640 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 42 ms
47,500 KB |
testcase_11 | AC | 616 ms
55,784 KB |
testcase_12 | AC | 522 ms
55,604 KB |
testcase_13 | AC | 534 ms
55,068 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 446 ms
55,648 KB |
testcase_18 | AC | 406 ms
55,552 KB |
testcase_19 | WA | - |
ソースコード
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; } } } }