結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
|
提出日時 | 2014-10-11 03:29:01 |
言語 | Java17 (openjdk 17.0.1) |
結果 |
AC
|
実行時間 | 772 ms / 5,000 ms |
コード長 | 1,932 bytes |
コンパイル時間 | 2,980 ms |
使用メモリ | 46,468 KB |
最終ジャッジ日時 | 2023-01-21 13:37:39 |
合計ジャッジ時間 | 13,695 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 108 ms
38,096 KB |
testcase_01 | AC | 110 ms
38,092 KB |
testcase_02 | AC | 772 ms
46,196 KB |
testcase_03 | AC | 644 ms
45,384 KB |
testcase_04 | AC | 519 ms
46,324 KB |
testcase_05 | AC | 442 ms
46,316 KB |
testcase_06 | AC | 345 ms
45,860 KB |
testcase_07 | AC | 139 ms
38,728 KB |
testcase_08 | AC | 370 ms
46,284 KB |
testcase_09 | AC | 760 ms
46,204 KB |
testcase_10 | AC | 109 ms
38,108 KB |
testcase_11 | AC | 741 ms
45,732 KB |
testcase_12 | AC | 704 ms
46,468 KB |
testcase_13 | AC | 666 ms
46,448 KB |
testcase_14 | AC | 765 ms
46,156 KB |
testcase_15 | AC | 718 ms
45,824 KB |
testcase_16 | AC | 215 ms
42,944 KB |
testcase_17 | AC | 583 ms
45,992 KB |
testcase_18 | AC | 525 ms
46,348 KB |
testcase_19 | AC | 179 ms
39,804 KB |
ソースコード
import java.util.*; 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; static int K = 10000; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); N = scanner.nextInt(); int[] party = new int[N]; int[] enemy = new int[N]; 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"); } }