結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
|
提出日時 | 2014-10-11 03:29:01 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 947 ms / 5,000 ms |
コード長 | 1,932 bytes |
コンパイル時間 | 4,695 ms |
コンパイル使用メモリ | 85,420 KB |
実行使用メモリ | 61,072 KB |
最終ジャッジ日時 | 2024-06-23 21:58:05 |
合計ジャッジ時間 | 15,680 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
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"); } }