結果

問題 No.77 レンガのピラミッド
ユーザー Mcpu3Mcpu3
提出日時 2018-09-13 00:49:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 147 ms / 5,000 ms
コード長 597 bytes
コンパイル時間 2,248 ms
コンパイル使用メモリ 77,716 KB
実行使用メモリ 41,940 KB
最終ジャッジ日時 2024-06-28 09:38:19
合計ジャッジ時間 6,685 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,136 KB
testcase_01 AC 134 ms
40,952 KB
testcase_02 AC 133 ms
41,292 KB
testcase_03 AC 129 ms
40,788 KB
testcase_04 AC 132 ms
41,036 KB
testcase_05 AC 131 ms
41,124 KB
testcase_06 AC 138 ms
41,096 KB
testcase_07 AC 136 ms
41,424 KB
testcase_08 AC 147 ms
41,388 KB
testcase_09 AC 118 ms
40,004 KB
testcase_10 AC 135 ms
41,424 KB
testcase_11 AC 135 ms
40,944 KB
testcase_12 AC 139 ms
41,236 KB
testcase_13 AC 140 ms
41,124 KB
testcase_14 AC 142 ms
41,564 KB
testcase_15 AC 133 ms
40,940 KB
testcase_16 AC 134 ms
41,064 KB
testcase_17 AC 135 ms
41,312 KB
testcase_18 AC 145 ms
41,572 KB
testcase_19 AC 137 ms
41,940 KB
testcase_20 AC 136 ms
40,960 KB
testcase_21 AC 142 ms
41,204 KB
testcase_22 AC 135 ms
41,340 KB
testcase_23 AC 140 ms
41,196 KB
testcase_24 AC 134 ms
41,372 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