結果
| 問題 | 
                            No.9 モンスターのレベル上げ
                             | 
                    
| コンテスト | |
| ユーザー | 
                             core123
                         | 
                    
| 提出日時 | 2019-04-18 10:02:47 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1,214 ms / 5,000 ms | 
| コード長 | 1,601 bytes | 
| コンパイル時間 | 2,470 ms | 
| コンパイル使用メモリ | 79,836 KB | 
| 実行使用メモリ | 60,816 KB | 
| 最終ジャッジ日時 | 2024-09-22 08:49:17 | 
| 合計ジャッジ時間 | 17,218 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 | 
ソースコード
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<>();
			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 implements Comparable<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);
		}
		@Override
		public int compareTo(Pair p){
			int value=Integer.compare(x,p.x);
			if(value!=0){
				return value;
			}
			return Integer.compare(y,p.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));
    }
}
            
            
            
        
            
core123