結果

問題 No.77 レンガのピラミッド
ユーザー ty70ty70
提出日時 2015-06-08 03:05:58
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,780 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 88,552 KB
実行使用メモリ 5,256 KB
最終ジャッジ日時 2023-09-20 19:45:36
合計ジャッジ時間 1,621 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define each(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizoef(a))
#define sz(s) (int)((s).size())
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define pb push_back
#define MP(x,y) make_pair((x),(y))
#define EPS 1e-6
#define INF 1<<20

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	int N; cin >> N;
	vector<int> a(N, 0 );
	
	int sum = 0;
	rep (i, N ) cin >> a[i], sum += a[i];

	int res = INF;
	for (int h = 1; h <= (int)sqrt(sum+EPS ); h++ ){
		int curr = 0;
//		cerr << "hight: " << h << endl;
		rep (i, max (2*h-1, N ) ){
			int block = (int)max (0, (i < h ? i + 1 : 2*h - (i + 1 ) ) );
//			cerr << "a: " << setw(2) << a[i] << " block: " << block << endl;
			curr += max(a[i] - block, 0  );
		} // end rep
		res = min (res, curr );
//		cerr << "res: " << res << endl;
	} // end for
	
	cout << res << endl;

	return 0;
}
0