結果

問題 No.77 レンガのピラミッド
ユーザー ぴろずぴろず
提出日時 2014-12-11 11:49:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 714 bytes
コンパイル時間 3,267 ms
コンパイル使用メモリ 73,556 KB
実行使用メモリ 56,256 KB
最終ジャッジ日時 2023-09-02 13:58:29
合計ジャッジ時間 6,997 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,960 KB
testcase_01 AC 124 ms
55,588 KB
testcase_02 AC 125 ms
55,588 KB
testcase_03 AC 124 ms
55,980 KB
testcase_04 AC 125 ms
55,804 KB
testcase_05 AC 128 ms
55,628 KB
testcase_06 AC 137 ms
55,756 KB
testcase_07 AC 126 ms
55,972 KB
testcase_08 AC 137 ms
56,048 KB
testcase_09 AC 126 ms
55,792 KB
testcase_10 AC 128 ms
55,416 KB
testcase_11 AC 127 ms
56,256 KB
testcase_12 AC 130 ms
55,424 KB
testcase_13 AC 133 ms
55,744 KB
testcase_14 AC 134 ms
55,880 KB
testcase_15 AC 128 ms
55,724 KB
testcase_16 AC 130 ms
56,064 KB
testcase_17 AC 126 ms
55,616 KB
testcase_18 AC 130 ms
53,988 KB
testcase_19 AC 124 ms
55,808 KB
testcase_20 AC 128 ms
55,468 KB
testcase_21 AC 130 ms
55,668 KB
testcase_22 AC 127 ms
56,084 KB
testcase_23 AC 129 ms
55,684 KB
testcase_24 AC 125 ms
55,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no077;

import java.util.Scanner;

public class Main {
	public static final int MAX = 300;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[MAX];
		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		int ans = 10000000;
		for(int i=1;i<=201;i+=2) {
			int[] b = new int[MAX];
			for(int k=0;k<i;k++) {
				b[k] = (i+1)/2 - Math.abs(i/2-k);
			}
			int x = 0;
			int y = 0;
			for(int k=0;k<MAX;k++) {
				if (a[k] >= b[k]) {
					x += a[k] - b[k];
				}else{
					y += b[k] - a[k];
				}
			}
			if (x < y) {
				continue;
			}
			ans = Math.min(ans, x);
		}
		System.out.println(ans);
	}

}
0