結果

問題 No.77 レンガのピラミッド
ユーザー リチウムリチウム
提出日時 2014-11-26 22:07:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 5,000 ms
コード長 591 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 71,300 KB
実行使用メモリ 58,156 KB
最終ジャッジ日時 2023-09-01 22:16:32
合計ジャッジ時間 6,752 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,464 KB
testcase_01 AC 119 ms
58,156 KB
testcase_02 AC 121 ms
55,592 KB
testcase_03 AC 122 ms
55,484 KB
testcase_04 AC 119 ms
55,424 KB
testcase_05 AC 120 ms
56,020 KB
testcase_06 AC 131 ms
56,340 KB
testcase_07 AC 119 ms
55,424 KB
testcase_08 AC 130 ms
56,384 KB
testcase_09 AC 122 ms
55,832 KB
testcase_10 AC 122 ms
55,584 KB
testcase_11 AC 122 ms
55,784 KB
testcase_12 AC 127 ms
55,948 KB
testcase_13 AC 130 ms
55,680 KB
testcase_14 AC 128 ms
55,860 KB
testcase_15 AC 121 ms
56,020 KB
testcase_16 AC 120 ms
55,972 KB
testcase_17 AC 124 ms
55,484 KB
testcase_18 AC 126 ms
56,268 KB
testcase_19 AC 119 ms
55,692 KB
testcase_20 AC 125 ms
56,028 KB
testcase_21 AC 125 ms
55,888 KB
testcase_22 AC 125 ms
56,052 KB
testcase_23 AC 126 ms
54,056 KB
testcase_24 AC 118 ms
55,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import static java.lang.Math.*;

public class Main {
	
	
  public static void main(String[] args) {
	  Scanner sc=new Scanner(System.in);
	  int n=sc.nextInt();
	  int A[]=new int[10000];
	  int sum=0;
	  for(int i=0;i<n;i++){
		  A[i]=sc.nextInt();
		  sum+=A[i];
	  }
	  int w=(int)pow(sum,0.5);
	  int end=w*2-2;
	  int ans=0;
	  for(int i=0;i<w;i++){
		  ans+=max(A[i]-(i+1),0);
	  }
	  for(int i=w;i<=end;i++){
		  ans+=max(0,A[i]-(end-i+1));
	  }
	  for(int i=end+1;i<10000;i++){
		  ans+=A[i];
	  }
	  System.out.println(ans);
	  
  }}
0