結果

問題 No.9 モンスターのレベル上げ
ユーザー こるこる
提出日時 2017-01-07 14:28:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 672 ms / 5,000 ms
コード長 1,601 bytes
コンパイル時間 3,273 ms
コンパイル使用メモリ 75,448 KB
実行使用メモリ 57,956 KB
最終ジャッジ日時 2023-09-06 05:05:15
合計ジャッジ時間 10,967 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,512 KB
testcase_01 AC 44 ms
49,384 KB
testcase_02 AC 575 ms
56,972 KB
testcase_03 AC 424 ms
57,300 KB
testcase_04 AC 315 ms
57,344 KB
testcase_05 AC 274 ms
56,240 KB
testcase_06 AC 176 ms
56,312 KB
testcase_07 AC 60 ms
51,644 KB
testcase_08 AC 199 ms
56,356 KB
testcase_09 AC 549 ms
57,800 KB
testcase_10 AC 43 ms
49,388 KB
testcase_11 AC 672 ms
57,716 KB
testcase_12 AC 646 ms
57,596 KB
testcase_13 AC 535 ms
57,332 KB
testcase_14 AC 517 ms
57,164 KB
testcase_15 AC 557 ms
57,900 KB
testcase_16 AC 101 ms
52,240 KB
testcase_17 AC 416 ms
57,956 KB
testcase_18 AC 399 ms
57,824 KB
testcase_19 AC 88 ms
52,264 KB
権限があれば一括ダウンロードができます

ソースコード

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[j%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