結果

問題 No.9 モンスターのレベル上げ
ユーザー 37zigen37zigen
提出日時 2016-03-09 21:33:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,035 ms / 5,000 ms
コード長 1,283 bytes
コンパイル時間 2,347 ms
コンパイル使用メモリ 77,612 KB
実行使用メモリ 62,752 KB
最終ジャッジ日時 2023-09-06 04:31:23
合計ジャッジ時間 15,704 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 146 ms
56,316 KB
testcase_01 AC 144 ms
56,004 KB
testcase_02 AC 1,035 ms
62,440 KB
testcase_03 AC 850 ms
61,768 KB
testcase_04 AC 674 ms
62,112 KB
testcase_05 AC 582 ms
62,676 KB
testcase_06 AC 377 ms
62,088 KB
testcase_07 AC 181 ms
56,300 KB
testcase_08 AC 425 ms
61,600 KB
testcase_09 AC 1,028 ms
62,648 KB
testcase_10 AC 146 ms
55,836 KB
testcase_11 AC 989 ms
62,504 KB
testcase_12 AC 1,002 ms
62,680 KB
testcase_13 AC 762 ms
61,072 KB
testcase_14 AC 1,019 ms
62,292 KB
testcase_15 AC 949 ms
62,752 KB
testcase_16 AC 246 ms
58,440 KB
testcase_17 AC 826 ms
62,592 KB
testcase_18 AC 649 ms
62,320 KB
testcase_19 AC 216 ms
58,136 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