結果

問題 No.9 モンスターのレベル上げ
ユーザー こるこる
提出日時 2017-01-07 14:20:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,601 bytes
コンパイル時間 3,581 ms
コンパイル使用メモリ 75,612 KB
実行使用メモリ 59,728 KB
最終ジャッジ日時 2023-08-22 16:10:00
合計ジャッジ時間 11,483 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
49,580 KB
testcase_01 AC 47 ms
49,548 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 45 ms
47,612 KB
testcase_11 AC 672 ms
57,292 KB
testcase_12 AC 713 ms
57,708 KB
testcase_13 AC 517 ms
56,956 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
public class No009 {


    public static void main(String[] args) throws IOException {

        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int[] a=new int[n];
        int[] b=new int[n];
        StringTokenizer st=new StringTokenizer(br.readLine());
        for(int i=0;i<n;i++){ a[i]=Integer.parseInt(st.nextToken()); }
        st=new StringTokenizer(br.readLine());
        for(int i=0;i<n;i++){ b[i]=Integer.parseInt(st.nextToken())/2; }
        int max=0;
        int min=1000000000;
        for(int i=0;i<n;i++){
            Queue<zako> q=new PriorityQueue(new my());
            for(int nn:a){ q.add(new zako(nn,0));  }
            max=0;
            for(int j=i;j<n+i;j++){
                zako z=q.poll();
                z.level+=b[i%n];
                z.times++;
                if(z.times>min) break;
                if(z.times>max) max=z.times;
                q.add(z);
            }min=Math.min(min,max);
        }System.out.println(min);
    }
    
}

class my implements Comparator{
    public int compare(Object obj1,Object obj2){
        zako z1=(zako)obj1;
        zako z2=(zako)obj2;
        
        if(z1.times+z1.level*100000>z2.times+z2.level*100000){
            return 1;
        }else if(z1.times+z1.level*100000<z2.times+z2.level*100000){
            return -1;
        }else{
            return 0;
        }
    }
}

class zako{
    int level;
    int times;
    zako(int level,int times){
        this.level=level;
        this.times=times;
    }
}
0