結果

問題 No.9 モンスターのレベル上げ
コンテスト
ユーザー kou6839
提出日時 2014-11-09 16:33:51
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 495 ms / 5,000 ms
+ 298µs
コード長 1,117 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,550 ms
コンパイル使用メモリ 85,244 KB
実行使用メモリ 51,828 KB
最終ジャッジ日時 2026-07-28 08:01:03
合計ジャッジ時間 8,843 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.*;
 
class status implements Comparable<status>{
	int level;
	int count;
	status(int level,int count){
		this.level=level;
		this.count = count;
	}
	@Override
	public int compareTo(status arg0) {
		int value = this.level - arg0.level;
		if(value==0){
			return this.count-arg0.count;
		}
		return value;
	}
	
}
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] party = new int[N];
		int[] enemy = new int[N];
		for(int i=0;i<N;i++){
			party[i]=sc.nextInt();
		}
		for(int i=0;i<N;i++){
			enemy[i]=sc.nextInt();
		}
		int ans=Integer.MAX_VALUE;
		for(int i=0;i<N;i++){
			Queue<status> queue= new PriorityQueue<status>();
			for(int j=0;j<N;j++){
				queue.add(new status(party[j],0));
			}
			for(int j=0;j<N;j++){
				status temp = queue.poll();
				temp.level+=enemy[(i+j)%N]/2;
				temp.count++;
				queue.add(temp);
			}
			int max=0;
			for(status a:queue){
				max=Math.max(max, a.count);
			}
			ans=Math.min(ans,max);
		}
		System.out.println(ans);
	}
}	
0