結果

問題 No.77 レンガのピラミッド
ユーザー shimashima_k
提出日時 2015-04-28 17:24:54
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 400 bytes
コンパイル時間 1,393 ms
コンパイル使用メモリ 160,840 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 05:02:22
合計ジャッジ時間 2,210 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

int main() {
    int n, sum=0;
    vector<int> a;
    cin >> n;
    for(int i=0; i<n; i++) {
        int t;
        cin>>t;
        sum += t;
        a.push_back(t);
    }
    int x = (int)sqrt(sum+0.1);
    int ans = 0;
    for (int i=0; i<n; i++) {
        ans += max(0, a[i] - max(0, x - abs((x - 1) - i)));
    }
    cout<<ans<<endl;
    return 0;
}
0