結果
問題 | No.9 モンスターのレベル上げ |
ユーザー | yuki2006 |
提出日時 | 2014-10-11 03:34:35 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,038 ms / 5,000 ms |
コード長 | 1,906 bytes |
コンパイル時間 | 4,022 ms |
コンパイル使用メモリ | 80,448 KB |
実行使用メモリ | 64,060 KB |
最終ジャッジ日時 | 2023-09-06 03:07:40 |
合計ジャッジ時間 | 16,684 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 126 ms
55,688 KB |
testcase_01 | AC | 125 ms
55,872 KB |
testcase_02 | AC | 969 ms
62,044 KB |
testcase_03 | AC | 801 ms
60,504 KB |
testcase_04 | AC | 608 ms
61,976 KB |
testcase_05 | AC | 555 ms
64,060 KB |
testcase_06 | AC | 365 ms
61,540 KB |
testcase_07 | AC | 169 ms
55,816 KB |
testcase_08 | AC | 395 ms
61,852 KB |
testcase_09 | AC | 968 ms
62,692 KB |
testcase_10 | AC | 124 ms
56,056 KB |
testcase_11 | AC | 1,038 ms
63,100 KB |
testcase_12 | AC | 1,009 ms
62,104 KB |
testcase_13 | AC | 759 ms
61,452 KB |
testcase_14 | AC | 978 ms
62,320 KB |
testcase_15 | AC | 970 ms
62,620 KB |
testcase_16 | AC | 226 ms
58,288 KB |
testcase_17 | AC | 751 ms
61,896 KB |
testcase_18 | AC | 641 ms
62,448 KB |
testcase_19 | AC | 201 ms
55,804 KB |
ソースコード
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); } }