結果

問題 No.9 モンスターのレベル上げ
ユーザー 37zigen37zigen
提出日時 2016-03-09 21:33:31
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 801 ms / 5,000 ms
コード長 1,283 bytes
コンパイル時間 1,941 ms
使用メモリ 47,012 KB
最終ジャッジ日時 2023-01-21 15:30:29
合計ジャッジ時間 13,043 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 112 ms
38,292 KB
testcase_01 AC 114 ms
38,332 KB
testcase_02 AC 801 ms
46,108 KB
testcase_03 AC 692 ms
46,412 KB
testcase_04 AC 513 ms
45,512 KB
testcase_05 AC 441 ms
46,132 KB
testcase_06 AC 362 ms
45,748 KB
testcase_07 AC 142 ms
38,672 KB
testcase_08 AC 360 ms
47,012 KB
testcase_09 AC 751 ms
46,312 KB
testcase_10 AC 115 ms
38,172 KB
testcase_11 AC 738 ms
46,024 KB
testcase_12 AC 794 ms
46,280 KB
testcase_13 AC 704 ms
46,260 KB
testcase_14 AC 774 ms
46,236 KB
testcase_15 AC 702 ms
46,032 KB
testcase_16 AC 191 ms
43,000 KB
testcase_17 AC 591 ms
46,000 KB
testcase_18 AC 569 ms
46,688 KB
testcase_19 AC 182 ms
39,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
	}
}
0