結果

問題 No.9 モンスターのレベル上げ
ユーザー spaciaspacia
提出日時 2016-01-20 20:16:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 639 ms / 5,000 ms
コード長 1,471 bytes
コンパイル時間 2,398 ms
コンパイル使用メモリ 75,924 KB
実行使用メモリ 58,024 KB
最終ジャッジ日時 2023-09-06 04:27:28
合計ジャッジ時間 8,958 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
49,528 KB
testcase_01 AC 47 ms
49,996 KB
testcase_02 AC 438 ms
57,376 KB
testcase_03 AC 316 ms
57,348 KB
testcase_04 AC 338 ms
57,720 KB
testcase_05 AC 263 ms
57,096 KB
testcase_06 AC 155 ms
56,324 KB
testcase_07 AC 64 ms
52,304 KB
testcase_08 AC 165 ms
56,208 KB
testcase_09 AC 413 ms
57,740 KB
testcase_10 AC 46 ms
47,904 KB
testcase_11 AC 450 ms
57,408 KB
testcase_12 AC 639 ms
57,804 KB
testcase_13 AC 171 ms
56,812 KB
testcase_14 AC 450 ms
58,024 KB
testcase_15 AC 450 ms
57,732 KB
testcase_16 AC 96 ms
51,736 KB
testcase_17 AC 364 ms
57,724 KB
testcase_18 AC 346 ms
57,968 KB
testcase_19 AC 93 ms
51,740 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