結果

問題 No.9 モンスターのレベル上げ
ユーザー uafr_csuafr_cs
提出日時 2015-09-03 03:35:24
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 1,146 ms / 5,000 ms
コード長 1,601 bytes
コンパイル時間 1,747 ms
使用メモリ 47,900 KB
最終ジャッジ日時 2023-01-21 15:05:53
合計ジャッジ時間 15,431 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 96 ms
37,784 KB
testcase_01 AC 100 ms
37,832 KB
testcase_02 AC 1,146 ms
47,828 KB
testcase_03 AC 980 ms
47,728 KB
testcase_04 AC 643 ms
47,664 KB
testcase_05 AC 512 ms
47,136 KB
testcase_06 AC 378 ms
47,040 KB
testcase_07 AC 143 ms
38,376 KB
testcase_08 AC 392 ms
47,192 KB
testcase_09 AC 1,070 ms
47,820 KB
testcase_10 AC 100 ms
37,636 KB
testcase_11 AC 1,022 ms
47,256 KB
testcase_12 AC 932 ms
47,536 KB
testcase_13 AC 736 ms
47,588 KB
testcase_14 AC 1,059 ms
47,680 KB
testcase_15 AC 1,000 ms
47,900 KB
testcase_16 AC 218 ms
43,316 KB
testcase_17 AC 761 ms
47,604 KB
testcase_18 AC 719 ms
47,124 KB
testcase_19 AC 179 ms
40,372 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