結果

問題 No.9 モンスターのレベル上げ
ユーザー uafr_csuafr_cs
提出日時 2015-09-03 03:35:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,346 ms / 5,000 ms
コード長 1,601 bytes
コンパイル時間 2,281 ms
コンパイル使用メモリ 76,924 KB
実行使用メモリ 63,120 KB
最終ジャッジ日時 2023-09-06 04:16:06
合計ジャッジ時間 17,570 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,616 KB
testcase_01 AC 125 ms
55,948 KB
testcase_02 AC 1,346 ms
62,844 KB
testcase_03 AC 1,021 ms
63,048 KB
testcase_04 AC 779 ms
62,736 KB
testcase_05 AC 590 ms
62,772 KB
testcase_06 AC 421 ms
62,060 KB
testcase_07 AC 175 ms
55,840 KB
testcase_08 AC 463 ms
62,664 KB
testcase_09 AC 1,334 ms
62,732 KB
testcase_10 AC 124 ms
55,924 KB
testcase_11 AC 1,270 ms
62,844 KB
testcase_12 AC 1,226 ms
63,056 KB
testcase_13 AC 708 ms
60,512 KB
testcase_14 AC 1,319 ms
62,852 KB
testcase_15 AC 1,227 ms
62,492 KB
testcase_16 AC 228 ms
59,008 KB
testcase_17 AC 939 ms
63,120 KB
testcase_18 AC 805 ms
62,672 KB
testcase_19 AC 195 ms
58,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

public class Main {
	
	public static class Status implements Comparable<Status> {
		int level, count;
		
		public Status(int level, int count) {
			super();
			this.level = level;
			this.count = count;
		}
		
		@Override
		public int compareTo(Status o) {
			if(Integer.compare(this.level, o.level) != 0){
				return Integer.compare(this.level, o.level);
			}else{
				return Integer.compare(this.count, o.count);
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		int[] As = new int[N];
		int[] Bs = new int[N];
		
		for(int i = 0; i < N; i++){
			As[i] = sc.nextInt();
		}
		
		for(int i = 0; i < N; i++){
			Bs[i] = sc.nextInt();
		}
		
		int answer = Integer.MAX_VALUE;
		for(int B_start = 0; B_start < N; B_start++){
			
			PriorityQueue<Status> queue = new PriorityQueue<Status>();
			for(int i = 0; i < N; i++){
				queue.add(new Status(As[i], 0));
			}
			
			for(int i = 0; i < N; i++){
				final int B_battle = (B_start + i) % N;
				
				final Status A_battle = queue.poll();
				//System.out.println(B_start + " " + A_battle.level + " " + A_battle.count);
				
				A_battle.count++;
				A_battle.level += Bs[B_battle] / 2;
				queue.add(A_battle);
			}
			
			int max = Integer.MIN_VALUE;
			while(!queue.isEmpty()){
				max = Math.max(max, queue.poll().count);
			}
			
			answer = Math.min(answer, max);
		}
		
		System.out.println(answer);
	}

}
0