結果

問題 No.9 モンスターのレベル上げ
ユーザー リチウムリチウム
提出日時 2014-11-18 22:15:47
言語 Java19
(openjdk 21)
結果
AC  
実行時間 886 ms / 5,000 ms
コード長 1,176 bytes
コンパイル時間 2,876 ms
コンパイル使用メモリ 74,148 KB
実行使用メモリ 62,388 KB
最終ジャッジ日時 2023-09-06 03:14:24
合計ジャッジ時間 14,188 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,672 KB
testcase_01 AC 124 ms
55,804 KB
testcase_02 AC 860 ms
61,580 KB
testcase_03 AC 718 ms
61,428 KB
testcase_04 AC 594 ms
62,212 KB
testcase_05 AC 523 ms
62,240 KB
testcase_06 AC 326 ms
60,460 KB
testcase_07 AC 172 ms
55,632 KB
testcase_08 AC 387 ms
61,412 KB
testcase_09 AC 842 ms
61,672 KB
testcase_10 AC 121 ms
56,044 KB
testcase_11 AC 873 ms
61,452 KB
testcase_12 AC 851 ms
61,888 KB
testcase_13 AC 752 ms
61,452 KB
testcase_14 AC 886 ms
62,112 KB
testcase_15 AC 874 ms
62,112 KB
testcase_16 AC 208 ms
58,172 KB
testcase_17 AC 742 ms
61,896 KB
testcase_18 AC 639 ms
62,388 KB
testcase_19 AC 200 ms
58,352 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