結果

問題 No.77 レンガのピラミッド
ユーザー Mcpu3Mcpu3
提出日時 2018-09-13 00:49:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 597 bytes
コンパイル時間 4,936 ms
コンパイル使用メモリ 73,628 KB
実行使用メモリ 57,584 KB
最終ジャッジ日時 2023-09-10 18:26:35
合計ジャッジ時間 6,431 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,576 KB
testcase_01 AC 121 ms
57,520 KB
testcase_02 AC 120 ms
55,872 KB
testcase_03 AC 119 ms
55,564 KB
testcase_04 AC 119 ms
55,572 KB
testcase_05 AC 119 ms
56,088 KB
testcase_06 AC 130 ms
56,028 KB
testcase_07 AC 119 ms
55,900 KB
testcase_08 AC 128 ms
56,264 KB
testcase_09 AC 120 ms
56,164 KB
testcase_10 AC 120 ms
55,924 KB
testcase_11 AC 122 ms
56,016 KB
testcase_12 AC 126 ms
56,428 KB
testcase_13 AC 126 ms
55,564 KB
testcase_14 AC 128 ms
55,904 KB
testcase_15 AC 120 ms
55,772 KB
testcase_16 AC 131 ms
55,768 KB
testcase_17 AC 130 ms
55,904 KB
testcase_18 AC 137 ms
55,784 KB
testcase_19 AC 128 ms
55,568 KB
testcase_20 AC 120 ms
55,820 KB
testcase_21 AC 128 ms
55,564 KB
testcase_22 AC 124 ms
55,836 KB
testcase_23 AC 126 ms
55,772 KB
testcase_24 AC 120 ms
57,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int i,j;
        long N=sc.nextLong(),A[]=new long[199],t[]=new long[199],s=0,a=0;
        for(i=0;i<N;++i){
            A[i]=sc.nextLong();
            s+=A[i];
        }
        sc.close();
        for(i=1;(long)Math.pow((i+1)/2,2)<=s;i+=2);
        for(j=0;j<(i-1)/2;++j)t[j]=j+1;
        for(j=(i-1)/2;j<i-2;++j)t[j]=i-2-j;
        for(j=0;j<i-2;++j)if(t[j]>A[j])a+=t[j]-A[j];
        System.out.print(a+s-(long)Math.pow((i-1)/2,2));
    }
}
0