結果

問題 No.77 レンガのピラミッド
コンテスト
ユーザー Mcpu3
提出日時 2018-09-13 00:49:30
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 65 ms / 5,000 ms
コード長 597 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,693 ms
コンパイル使用メモリ 82,092 KB
実行使用メモリ 42,112 KB
最終ジャッジ日時 2026-03-16 23:07:02
合計ジャッジ時間 4,187 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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