結果
問題 | No.9 モンスターのレベル上げ |
ユーザー | tenten |
提出日時 | 2023-01-25 20:13:10 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,014 ms / 5,000 ms |
コード長 | 2,847 bytes |
コンパイル時間 | 3,050 ms |
コンパイル使用メモリ | 80,876 KB |
実行使用メモリ | 59,128 KB |
最終ジャッジ日時 | 2023-09-09 05:22:53 |
合計ジャッジ時間 | 14,277 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
49,416 KB |
testcase_01 | AC | 43 ms
49,660 KB |
testcase_02 | AC | 1,014 ms
58,748 KB |
testcase_03 | AC | 865 ms
58,952 KB |
testcase_04 | AC | 569 ms
58,988 KB |
testcase_05 | AC | 448 ms
58,844 KB |
testcase_06 | AC | 251 ms
57,272 KB |
testcase_07 | AC | 75 ms
51,232 KB |
testcase_08 | AC | 297 ms
58,972 KB |
testcase_09 | AC | 946 ms
58,140 KB |
testcase_10 | AC | 44 ms
49,708 KB |
testcase_11 | AC | 939 ms
58,552 KB |
testcase_12 | AC | 907 ms
58,380 KB |
testcase_13 | AC | 519 ms
57,268 KB |
testcase_14 | AC | 903 ms
58,604 KB |
testcase_15 | AC | 919 ms
59,128 KB |
testcase_16 | AC | 106 ms
52,552 KB |
testcase_17 | AC | 687 ms
58,844 KB |
testcase_18 | AC | 623 ms
58,944 KB |
testcase_19 | AC | 97 ms
52,400 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int[] levels = new int[n]; for (int i = 0; i < n; i++) { levels[i] = sc.nextInt(); } int[] enemies = new int[n]; for (int i = 0; i < n; i++) { enemies[i] = sc.nextInt() / 2; } PriorityQueue<Monster> side = new PriorityQueue<>(); int ans = Integer.MAX_VALUE; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { side.add(new Monster(levels[j])); } for (int j = 0; j < n; j++) { Monster x = side.poll(); x.add(enemies[(i + j) % n]); side.add(x); } int max = 0; while (side.size() > 0) { max = Math.max(max, side.poll().count); } ans = Math.min(ans, max); } System.out.println(ans); } static class Monster implements Comparable<Monster> { int value; int count; public Monster(int value) { this.value = value; } public void add(int x) { value += x; count++; } public int compareTo(Monster another) { if (value == another.value) { return count - another.count; } else { return value - another.value; } } } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }