結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
|
提出日時 | 2016-03-09 21:33:31 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 992 ms / 5,000 ms |
コード長 | 1,283 bytes |
コンパイル時間 | 2,307 ms |
コンパイル使用メモリ | 81,116 KB |
実行使用メモリ | 61,088 KB |
最終ジャッジ日時 | 2024-06-23 23:20:50 |
合計ジャッジ時間 | 14,934 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
import java.util.Date; import java.util.PriorityQueue; import java.util.Scanner; public class Main { static class Tuple implements Comparable<Tuple>{ int level; int count; Tuple(int level,int count){ this.level=level; this.count=count; } 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; public static void main(String[] args){ Scanner sc=new Scanner(System.in); n=sc.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]=sc.nextInt(); } for(int i=0;i<n;i++){ enemy[i]=sc.nextInt(); } int min=n; for(int i=0;i<n;i++){ PriorityQueue<Tuple> queue=new PriorityQueue<Tuple>(n); for(int j=0;j<n;j++){ queue.add(new Tuple(party[j],0)); } for(int k=0;k<n;k++){ Tuple t=queue.poll(); t.level+=enemy[(i+k)%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"); sc.close(); } }