結果

問題 No.77 レンガのピラミッド
ユーザー KKT89KKT89
提出日時 2020-10-15 19:09:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 890 bytes
コンパイル時間 1,946 ms
コンパイル使用メモリ 200,724 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-28 01:15:56
合計ジャッジ時間 3,443 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    vector<int> sum(n+1);
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum[i+1]=sum[i]+a[i];
    }
    int res=1e9;
    for(int i=1;i<=n;i+=2){
        int cnt=(i/2)*(i/2+1)+(i/2+1);
        if(sum[n]<cnt)continue;
        for(int j=0;j+i-1<n;j++){
            int aaa=0;
            bool f=false;
            int in=0,out=sum[n]-(sum[j+i]-sum[j]);
            for(int k=j;k<j+i;k++){
                if(!f){
                    aaa++;
                    if(aaa==(i/2+1))f=true;
                }
                else aaa--;
                if(a[k]>aaa)out+=a[k]-aaa;
                else in+=aaa-a[k];
            }
            res=min(res,max(in,out));
        }
    }
    printf("%d\n",res);
}
0