結果

問題 No.9 モンスターのレベル上げ
ユーザー nCk_cvnCk_cv
提出日時 2016-02-18 15:38:50
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 770 ms / 5,000 ms
コード長 1,051 bytes
コンパイル時間 1,830 ms
使用メモリ 46,668 KB
最終ジャッジ日時 2023-01-21 15:28:54
合計ジャッジ時間 12,290 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 100 ms
37,828 KB
testcase_01 AC 98 ms
37,704 KB
testcase_02 AC 770 ms
45,996 KB
testcase_03 AC 657 ms
46,412 KB
testcase_04 AC 493 ms
46,488 KB
testcase_05 AC 404 ms
45,784 KB
testcase_06 AC 303 ms
45,544 KB
testcase_07 AC 120 ms
38,492 KB
testcase_08 AC 311 ms
45,364 KB
testcase_09 AC 766 ms
46,628 KB
testcase_10 AC 97 ms
37,844 KB
testcase_11 AC 760 ms
46,156 KB
testcase_12 AC 694 ms
45,856 KB
testcase_13 AC 665 ms
46,048 KB
testcase_14 AC 715 ms
46,588 KB
testcase_15 AC 743 ms
46,624 KB
testcase_16 AC 166 ms
40,180 KB
testcase_17 AC 551 ms
46,668 KB
testcase_18 AC 514 ms
46,588 KB
testcase_19 AC 163 ms
40,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.awt.geom.*;
import java.io.*;

class Main {
	static int[] vx = {1,0,-1,0};
	static int[] vy = {0,1,0,-1};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			b[i] = sc.nextInt()/2;
		}
		int min = 2 << 29;
		for(int i = 0; i < n; i++) {
			PriorityQueue<Data> p = new PriorityQueue<Data>();
			for(int j = 0; j < n; j++) {
				p.add(new Data(a[j],0));
			}
			int max = 0;
			for(int j = 0; j < n; j++) {
				Data tmp = p.poll();
				tmp.b++;
				tmp.a += b[(j + i) % n];
				p.add(tmp);
				max = Math.max(max, tmp.b);
			}
			min = Math.min(min,max);
		}
		System.out.println(min);
		
	}
	static class Data implements Comparable<Data>{
		int a;
		int b;
		Data(int c, int d) {
			a = c;
			b = d;
		}
		@Override
		public int compareTo(Data o) {
			if(o.a == this.a) return this.b - o.b;
			return this.a - o.a;
		}
		
	}
}
0