結果

問題 No.9 モンスターのレベル上げ
ユーザー t8m8⛄️t8m8⛄️
提出日時 2016-02-12 00:55:11
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 745 ms / 5,000 ms
コード長 1,324 bytes
コンパイル時間 3,558 ms
使用メモリ 52,920 KB
最終ジャッジ日時 2023-01-21 15:27:53
合計ジャッジ時間 14,096 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 115 ms
46,112 KB
testcase_01 AC 114 ms
44,116 KB
testcase_02 AC 745 ms
50,500 KB
testcase_03 AC 678 ms
50,440 KB
testcase_04 AC 492 ms
50,252 KB
testcase_05 AC 414 ms
52,352 KB
testcase_06 AC 303 ms
52,248 KB
testcase_07 AC 132 ms
45,936 KB
testcase_08 AC 355 ms
50,476 KB
testcase_09 AC 729 ms
50,644 KB
testcase_10 AC 113 ms
43,900 KB
testcase_11 AC 721 ms
52,396 KB
testcase_12 AC 664 ms
49,932 KB
testcase_13 AC 663 ms
52,920 KB
testcase_14 AC 735 ms
52,344 KB
testcase_15 AC 708 ms
50,376 KB
testcase_16 AC 207 ms
45,648 KB
testcase_17 AC 574 ms
50,548 KB
testcase_18 AC 510 ms
52,300 KB
testcase_19 AC 187 ms
47,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No009 {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		PriorityQueue<int[]> pQ = new PriorityQueue<>(new Comparator<int[]>(){
			public int compare(int[] a, int[] b) {
				if (a[0] != b[0]) return a[0] - b[0];
				return a[1] - b[1];
			}
		});
		for (int i=0; i<n; i++) {
			pQ.add(new int[]{in.nextInt(), 0});
		}

		int[] b = new int[n];
		for (int i=0; i<n; i++) {
			b[i] = in.nextInt();
		}

		int min = Integer.MAX_VALUE/2;
		for (int i=0; i<n; i++) {
			PriorityQueue<int[]> q = new PriorityQueue<>(pQ);
			int max = 0;
			for (int j=i, c=0; c<n; j=(j+1)%n, c++) {
				int[] x = q.poll();
				q.add(new int[]{x[0] + b[j]/2, x[1] + 1});
				max = Math.max(max, x[1] + 1);
			}
			min = Math.min(min, max);
		}

		out.println(min);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		dump((end-start) + "ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}
0