結果

問題 No.77 レンガのピラミッド
ユーザー cherrypi59
提出日時 2018-10-11 15:55:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 533 bytes
コンパイル時間 1,422 ms
コンパイル使用メモリ 170,412 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-12 17:37:10
合計ジャッジ時間 2,180 ms
ジャッジサーバーID
(参考情報)
judge3 / judge
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    int n; cin>>n;
    vector<int> a(200); fill(a.begin(), a.end(), 0);
    for(int i=0;i<n;i++) cin>>a[i];

    int ans = 1e5;
    for(int i=1;i<=100;i++){
            int add = 0, sub = 0;
            for(int j=0;j<200;j++){
                if(max(i-abs(j-i+1), 0)<a[j]) sub += a[j] - max(i-abs(j-i+1), 0);
                else add += max(i-abs(j-i+1), 0) - a[j];
            }

            if(add<=sub) ans = min(ans, sub);
        }

    cout<<ans<<endl;
    return 0;
}
0