結果

問題 No.77 レンガのピラミッド
ユーザー spade630spade630
提出日時 2015-11-06 17:44:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,713 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 73,896 KB
実行使用メモリ 4,484 KB
最終ジャッジ日時 2023-10-11 14:22:57
合計ジャッジ時間 1,641 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
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 WA -
testcase_24 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <cstdlib>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=1e+5 + 1;
const ut INF=1<<29;
const ld eps=1e-6;
const LL mod=1e+6 + 3;

int N, A[128], blocks[128];
int sum;

int main() {
	cin >> N;
	REP(i,N){
		cin >> A[i];
		sum += A[i];
	}
	int L = (int)floor(sqrt(sum));
	L = (L - 1) * 2 + 1;
	int ans = 0;
	if(L >= N){
		for(int i = 0, k = 0; i < L; ++i){
			if(i >= L / 2 - N / 2 && A[k]){
				blocks[i] = A[k];
				k++;
			}
		}
		REP(i,L)
			A[i] = blocks[i];
		N = L;
		REP(i,N){
			if(i <= N / 2){
				int t = A[i] - (i + 1);
				if(t > 0){
					ans += t;
				}
			}
			else{
				int t = A[i] - (N - i);
				if(t > 0){
					ans += t;
				}
			}
		}
	}
	else if(L < N){
		ans += sum - (int)pow((L + 1) / 2, 2);
		int d = (N - L) / 2;
		for(int i = 0; i < N; ++i){
			if(i >= d && i <= N / 2){
				int t = (i - d + 1) - A[i];
				if(t > 0)
					ans += t;
			}
			else if(i > N / 2 && i < N - d){
				int t = (N - d - i) - A[i];
				if(t > 0)
					ans += t;
			}
		}
	}
	cout << ans << endl;
	/*REP(i,N){
		if(i)
			cout << " ";
		cout << A[i];
	}
	cout << endl;*/
 	return 0;
}
0