結果
問題 |
No.77 レンガのピラミッド
|
ユーザー |
![]() |
提出日時 | 2015-04-24 17:46:04 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,238 bytes |
コンパイル時間 | 2,043 ms |
コンパイル使用メモリ | 77,220 KB |
実行使用メモリ | 56,164 KB |
最終ジャッジ日時 | 2024-07-05 00:51:06 |
合計ジャッジ時間 | 6,397 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 4 |
other | AC * 1 WA * 8 RE * 11 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner koko = new Scanner(System.in); int n = koko.nextInt(); int[] a = new int[n]; int total =0; for(int i=0; i<n; i++){ a[i]=koko.nextInt(); total=total+a[i]; } int idou = total; int c = 1; for(int i=1; i*i<=total; i+=2){ int put=0; int rem=0; for(int j=0; j<(i-1)/2; j++){ if(a[j]<=c){ put=put+c-a[j]; }else{ rem=rem+a[j]-c; } c++; } for(int j=(i-1)/2; j<i-1; j++){ if(a[j]<=c){ put=put+c-a[j]; }else{ rem=rem+a[j]-c; } c--; } if(a[i-1]<=c){ put=put+c-a[i-1]; }else{ rem=rem+a[i-1]-c; } for(int j=i; j<n; j++){ rem=rem+a[j]; } idou=Math.min(idou, Math.max(rem, put)); } System.out.println(idou); } }