結果

問題 No.9 モンスターのレベル上げ
ユーザー リチウムリチウム
提出日時 2014-11-18 22:15:47
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 821 ms / 5,000 ms
コード長 1,176 bytes
コンパイル時間 1,686 ms
使用メモリ 47,260 KB
最終ジャッジ日時 2023-01-21 13:46:38
合計ジャッジ時間 12,815 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 97 ms
37,784 KB
testcase_01 AC 96 ms
37,708 KB
testcase_02 AC 821 ms
47,216 KB
testcase_03 AC 646 ms
46,736 KB
testcase_04 AC 568 ms
47,260 KB
testcase_05 AC 480 ms
47,180 KB
testcase_06 AC 315 ms
45,796 KB
testcase_07 AC 127 ms
38,328 KB
testcase_08 AC 365 ms
46,352 KB
testcase_09 AC 737 ms
44,864 KB
testcase_10 AC 94 ms
37,872 KB
testcase_11 AC 798 ms
46,804 KB
testcase_12 AC 731 ms
46,848 KB
testcase_13 AC 703 ms
46,824 KB
testcase_14 AC 770 ms
46,428 KB
testcase_15 AC 701 ms
46,512 KB
testcase_16 AC 211 ms
44,264 KB
testcase_17 AC 587 ms
47,220 KB
testcase_18 AC 561 ms
47,008 KB
testcase_19 AC 169 ms
40,724 KB
権限があれば一括ダウンロードができます

ソースコード

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