結果
| 問題 | 
                            No.77 レンガのピラミッド
                             | 
                    
| コンテスト | |
| ユーザー | 
                             spade630
                         | 
                    
| 提出日時 | 2015-11-06 17:44:05 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,713 bytes | 
| コンパイル時間 | 775 ms | 
| コンパイル使用メモリ | 74,912 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-09-13 13:04:44 | 
| 合計ジャッジ時間 | 1,694 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 WA * 1 | 
| other | AC * 2 WA * 18 | 
ソースコード
#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;
}
            
            
            
        
            
spade630