結果

問題 No.77 レンガのピラミッド
ユーザー なおなお
提出日時 2014-11-25 23:48:30
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,104 bytes
コンパイル時間 1,116 ms
コンパイル使用メモリ 144,656 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-31 01:15:28
合計ジャッジ時間 1,941 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))
#define REPEAT(i, k, n)     for(int(i)=(k);(i)<((k)+(n));++(i))

int k[1000];
int l[1000];
int m[1000];

int main(){
    int N;
    cin >> N;
    REP(i,N) cin >> k[i];
    
    int minv = 1<<29;
    for(int i = 1; i < 1000; i += 2){
        memcpy(l, k, sizeof(k));
        memset(m,0,sizeof(m));

        for(int j = 0; j < i; j++){
            m[j] = j+1;
            if(j > i/2) m[j] = i-j;
        }

        int c = 0;
        for(int j = 0; j < max(i,N); j++){
            if(l[j] <= m[j]) continue;
            int n = l[j]-m[j]; l[j] = m[j];
            c += n;
            for(int k = 0; k < N && n; k++){
                while(n && l[k] < m[k]){
                    l[k]++, n--;
                }
            }
        }
        bool f = true;
        for(int j = 0; j < i; j++){
            if(l[j] != m[j]) {f = false; break; }
        }
        if(f) minv = min(minv, c);
    }
    cout << minv << endl;

    return 0;
}
0