結果

問題 No.77 レンガのピラミッド
ユーザー RCCWRCCW
提出日時 2017-02-18 22:23:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 971 bytes
コンパイル時間 1,208 ms
コンパイル使用メモリ 144,516 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-28 18:54:39
合計ジャッジ時間 2,563 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,504 KB
testcase_24 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int d[30];
/*
{小さなピラミッド}⊂{大きなピラミッド}なので
{小さなピラミッドを作るため動かさないレンガ}⊂{大きなピラミッドを作るため動かさないレンガ}
となる。よって可能な限り大きなサイズのピラミッドを作れば良い
中心の高さがkであるようなピラミッドにはk^2個のレンガが必要なので
作ることができるピラミッドの最大サイズはレンガの総数の平方根となる
「動かすレンガの数」は面倒なので「動かさないレンガの数」を全体から引く
*/
int main(){
	int a[205],n,m,i,s=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		cin>>a[i];
	}

	for(i=1;i<=n;i++)s+=a[i];
	m=sqrt(s);
	for(i=1;i<=m;i++)s-=min(a[i],i);
	for(i=m+1;i<2*m;i++)s-=min(a[i],2*m-i);
	printf("%d",s);
	return 0;
}
0