結果

問題 No.9 モンスターのレベル上げ
ユーザー リチウム
提出日時 2014-11-18 22:15:47
言語 Java
(openjdk 23)
結果
AC  
実行時間 866 ms / 5,000 ms
コード長 1,176 bytes
コンパイル時間 2,350 ms
コンパイル使用メモリ 79,204 KB
実行使用メモリ 60,512 KB
最終ジャッジ日時 2024-06-23 22:05:52
合計ジャッジ時間 13,629 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int friend[]=new int[n];
		int enemy[]=new int[n];
		for(int i=0;i<n;i++){
			friend[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++){
			PriorityQueue<conect>Q=new PriorityQueue<>();
			int times[]=new int[n];
			for(int j=0;j<n;j++){
				Q.add(new conect(friend[j],0,j));
			}
			for(int j=0;j<n;j++){
				int Enum=j+i;
				if(j+i>=n)Enum-=n;
				conect x=Q.poll();
				int y=x.l+enemy[Enum]/2;
				times[x.n]++;
				Q.add(new conect(y,times[x.n],x.n));
			}
			int ansk=0;
			for(int j=0;j<n;j++){
				ansk=Math.max(times[j],ansk);
			}
			ans=Math.min(ansk,ans);
		}
		System.out.println(ans);
	}}

class conect implements Comparable<conect> {
	int l;
	int t;
	int n;

	public conect(int l, int t, int n) {
		this.l = l;
		this.t = t;
		this.n = n;
	}

	public conect() {
	}

	@Override
	public int compareTo(conect o) {
		if(this.l!=o.l)	return this.l - o.l;
		return this.t-o.t;
	}

}
0