結果

問題 No.9 モンスターのレベル上げ
ユーザー core123core123
提出日時 2019-04-18 10:35:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,596 ms / 5,000 ms
コード長 1,476 bytes
コンパイル時間 5,056 ms
コンパイル使用メモリ 83,612 KB
実行使用メモリ 64,056 KB
最終ジャッジ日時 2023-10-22 08:06:43
合計ジャッジ時間 21,899 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
57,956 KB
testcase_01 AC 145 ms
57,660 KB
testcase_02 AC 1,596 ms
63,616 KB
testcase_03 AC 1,150 ms
62,356 KB
testcase_04 AC 770 ms
62,196 KB
testcase_05 AC 704 ms
63,320 KB
testcase_06 AC 454 ms
63,336 KB
testcase_07 AC 198 ms
58,068 KB
testcase_08 AC 549 ms
63,468 KB
testcase_09 AC 1,466 ms
63,428 KB
testcase_10 AC 143 ms
57,864 KB
testcase_11 AC 1,460 ms
63,296 KB
testcase_12 AC 1,524 ms
63,516 KB
testcase_13 AC 1,092 ms
64,056 KB
testcase_14 AC 1,478 ms
63,284 KB
testcase_15 AC 1,384 ms
63,552 KB
testcase_16 AC 271 ms
60,396 KB
testcase_17 AC 1,087 ms
63,408 KB
testcase_18 AC 940 ms
63,344 KB
testcase_19 AC 238 ms
60,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.util.stream.*;
import static java.lang.Math.*;
public class Main{
	public static void main(String... args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		int[] b=new int[n];
		for(int i=0;i<n;i++){
			b[i]=sc.nextInt();
		}
		int min=Integer.MAX_VALUE;
		for(int s=0;s<n;s++){
			PriorityQueue<Pair> pq=new PriorityQueue<>(Comparator.comparingInt((Pair p)->p.x).thenComparingInt(p->p.y));
			for(int i=0;i<n;i++){
				pq.add(new Pair(a[i],0));
			}
			for(int j=0;j<n;j++){
				int index=(s+j)%n;
				Pair p=pq.poll();
				p.x+=b[index]/2;
				p.y++;
				pq.add(p);
			}
			int max=Integer.MIN_VALUE;
			while(pq.size()>0){
				max=max(max,pq.poll().y);
			}
			min=min(min,max);
		}
		put(min);
	}
	public static class Pair{
		int x,y;
		Pair(int x,int y){
			this.x=x;
			this.y=y;
		}
		@Override
		public String toString(){
			return String.format("Pair(%d,%d)",x,y);
		}
	}
	public static void print(Object object){
        System.out.print(object);
    }
    public static void put(Object object) {
        System.out.println(object);
    }
    public static void put(){
        System.out.println();
    }
 
    public static void print(String format,Object... args){
        System.out.print(String.format(format,args));
    }
    public static void put(String format,Object... args) {
        System.out.println(String.format(format,args));
    }
}
0