結果
| 問題 | No.77 レンガのピラミッド |
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-02-19 11:59:30 |
| 言語 | C++11(old_compat) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 580 bytes |
| 記録 | |
| コンパイル時間 | 935 ms |
| コンパイル使用メモリ | 167,940 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-03-08 16:05:35 |
| 合計ジャッジ時間 | 1,578 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define RREP(i,s,e) for (int i = e-1; i >= s; i--)
#define rrep(i,n) RREP(i,0,n)
#define REP(i,s,e) for (int i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
int main() {
int n, sum, height, ans;
cin >> n;
int a[n];
rep (i,n) cin >> a[i];
sum = accumulate(a,a+n,0);
height = sqrt(sum);
ans = 0;
rep (i,min(n,height*2 - 1))
ans += max(0, a[i] - min(i+1,height*2 - 1 - i));
REP (i,height*2 - 1,n)
ans += a[i];
cout << ans << endl;
return 0;
}
h_noson