結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,352 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,352 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 2 ms
4,352 KB
testcase_18 AC 1 ms
4,352 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,352 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 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 = sum - (int)pow((L + 1) / 2, 2);
	int d = max(0, (N - L) / 2);
    N = L;
	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;
	/*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 += ;
		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