結果

問題 No.77 レンガのピラミッド
ユーザー Mcpu3Mcpu3
提出日時 2018-09-13 00:49:30
言語 Java
(openjdk 23)
結果
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
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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