結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
![]() |
提出日時 | 2016-02-18 15:38:50 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 850 ms / 5,000 ms |
コード長 | 1,051 bytes |
コンパイル時間 | 2,389 ms |
コンパイル使用メモリ | 79,120 KB |
実行使用メモリ | 59,592 KB |
最終ジャッジ日時 | 2024-06-23 23:19:52 |
合計ジャッジ時間 | 13,024 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
import java.util.*; import java.awt.geom.*; import java.io.*; class Main { static int[] vx = {1,0,-1,0}; static int[] vy = {0,1,0,-1}; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; int[] b = new int[n]; for(int i = 0; i < n; i++) { a[i] = sc.nextInt(); } for(int i = 0; i < n; i++) { b[i] = sc.nextInt()/2; } int min = 2 << 29; for(int i = 0; i < n; i++) { PriorityQueue<Data> p = new PriorityQueue<Data>(); for(int j = 0; j < n; j++) { p.add(new Data(a[j],0)); } int max = 0; for(int j = 0; j < n; j++) { Data tmp = p.poll(); tmp.b++; tmp.a += b[(j + i) % n]; p.add(tmp); max = Math.max(max, tmp.b); } min = Math.min(min,max); } System.out.println(min); } static class Data implements Comparable<Data>{ int a; int b; Data(int c, int d) { a = c; b = d; } @Override public int compareTo(Data o) { if(o.a == this.a) return this.b - o.b; return this.a - o.a; } } }