結果
問題 | No.77 レンガのピラミッド |
ユーザー |
![]() |
提出日時 | 2016-11-18 01:57:57 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 128 ms / 5,000 ms |
コード長 | 803 bytes |
コンパイル時間 | 2,370 ms |
コンパイル使用メモリ | 74,852 KB |
実行使用メモリ | 41,876 KB |
最終ジャッジ日時 | 2024-11-26 03:30:21 |
合計ジャッジ時間 | 6,798 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int [] A = new int [N]; int sum =0; for(int i=0; i<N; i++){ A[i] = sc.nextInt(); sum+=A[i]; } int p = (int)Math.sqrt(sum); int z = 2*p-1; int move = 0; for(int i=0; i<N; i++){ if(i<=p-1){ int t=A[i]-(i+1); if(t>0){ move+=t; } }else if(i<=z-1){ int t=A[i]-(z-i); if(t>0){ move+=t; } }else{ move+=A[i]; } } System.out.println(move); } }