結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
|
提出日時 | 2016-03-05 19:48:05 |
言語 | Java17 (openjdk 17.0.1) |
結果 |
AC
|
実行時間 | 708 ms / 5,000 ms |
コード長 | 2,724 bytes |
コンパイル時間 | 3,088 ms |
使用メモリ | 55,428 KB |
最終ジャッジ日時 | 2023-01-21 15:29:43 |
合計ジャッジ時間 | 12,043 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
47,876 KB |
testcase_01 | AC | 53 ms
47,904 KB |
testcase_02 | AC | 690 ms
53,524 KB |
testcase_03 | AC | 558 ms
53,312 KB |
testcase_04 | AC | 425 ms
52,724 KB |
testcase_05 | AC | 343 ms
55,248 KB |
testcase_06 | AC | 233 ms
55,304 KB |
testcase_07 | AC | 73 ms
44,624 KB |
testcase_08 | AC | 260 ms
53,300 KB |
testcase_09 | AC | 684 ms
55,428 KB |
testcase_10 | AC | 54 ms
47,776 KB |
testcase_11 | AC | 708 ms
52,804 KB |
testcase_12 | AC | 620 ms
52,544 KB |
testcase_13 | AC | 483 ms
53,756 KB |
testcase_14 | AC | 659 ms
53,280 KB |
testcase_15 | AC | 612 ms
55,040 KB |
testcase_16 | AC | 136 ms
47,004 KB |
testcase_17 | AC | 498 ms
54,100 KB |
testcase_18 | AC | 452 ms
53,716 KB |
testcase_19 | AC | 127 ms
49,164 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.PriorityQueue; public class Main_yukicoder9 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int n = sc.nextInt(); List<Integer> a = new ArrayList<Integer>(); List<Integer> b = new ArrayList<Integer>(); for (int i = 0; i < n; i++) { a.add(sc.nextInt()); } for (int i = 0; i < n; i++) { b.add(sc.nextInt()); } int min = Integer.MAX_VALUE; for (int i = 0; i < n; i++) { PriorityQueue<Monster> pq = new PriorityQueue<Monster>(); for (int j = 0; j < n; j++) { pq.add(new Monster(a.get(j))); } int max = 0; for (int j = 0; j < n; j++) { Monster m = pq.remove(); m.lv += b.get((i + j) % n) / 2; m.cnt++; max = Math.max(max, m.cnt); pq.add(m); } min = Math.min(min, max); } pr.println(min); pr.close(); sc.close(); } private static class Monster implements Comparable<Monster> { int lv; int cnt; Monster(int lv) { this.lv = lv; cnt = 0; } @Override public int compareTo(Monster o) { if (this.lv != o.lv) { return Integer.compare(this.lv, o.lv); } return Integer.compare(this.cnt, o.cnt); } } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator<String> it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }