結果

問題 No.9 モンスターのレベル上げ
ユーザー spaciaspacia
提出日時 2016-01-20 20:16:18
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 507 ms / 5,000 ms
コード長 1,471 bytes
コンパイル時間 2,749 ms
使用メモリ 43,736 KB
最終ジャッジ日時 2023-01-21 15:25:12
合計ジャッジ時間 8,890 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 54 ms
34,300 KB
testcase_01 AC 53 ms
34,300 KB
testcase_02 AC 366 ms
42,040 KB
testcase_03 AC 333 ms
43,424 KB
testcase_04 AC 258 ms
43,624 KB
testcase_05 AC 268 ms
43,332 KB
testcase_06 AC 180 ms
42,556 KB
testcase_07 AC 72 ms
34,632 KB
testcase_08 AC 176 ms
42,096 KB
testcase_09 AC 341 ms
42,164 KB
testcase_10 AC 52 ms
34,284 KB
testcase_11 AC 405 ms
42,812 KB
testcase_12 AC 507 ms
42,888 KB
testcase_13 AC 169 ms
40,940 KB
testcase_14 AC 338 ms
42,704 KB
testcase_15 AC 345 ms
42,176 KB
testcase_16 AC 108 ms
37,068 KB
testcase_17 AC 295 ms
42,644 KB
testcase_18 AC 301 ms
43,736 KB
testcase_19 AC 117 ms
36,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Main {
	
	static int len;
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static int[] sort (int[] a) {
		for (int i = 1; i < len; i++) {
			if (a[0] > a[i]) {
				int tmp = a[0];
				a[0] = a[i];
				a[i] = tmp;
			}
		}
		return a;
	}
	
	public static int solve (int[] levelM , int[] levelE) {
		int ret = Integer.MAX_VALUE , maxI = -1;
		int[] bk = Arrays.copyOf(levelM , len);
		main:for (int i = 0; i < len; i++) {
			int win = 0;
			PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
			for (int j = 0; j < len; j++) pq.add(bk[j]);
			for (int j = i; win++ < len; j++) {
				j %= len;
				int p = pq.poll();
				p += levelE[j] + 1;
				if ((p & 0xfff) >= ret) continue main;
				pq.add(p);
			}
			int max = 0;
			for (int j = 0; j < len; j++)
				max = Math.max(max , pq.poll() & 0xfff);
			ret = Math.min(ret , max);
		}
		return ret;
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		len = Integer.parseInt(br.readLine());
		String[] line1 = br.readLine().split(" ");
		int[] levelM = new int[len];
		String[] line2 = br.readLine().split(" ");
		int[] levelE = new int[len];
		
		for (int i = 0; i < len; i++) {
			levelM[i] = Integer.parseInt(line1[i]) << 12;
			levelE[i] = (Integer.parseInt(line2[i]) >> 1) << 12;
		}
		
		out(solve(levelM , levelE));
	}
}
0