結果

問題 No.77 レンガのピラミッド
ユーザー utouto97utouto97
提出日時 2019-03-19 20:09:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 933 bytes
コンパイル時間 1,645 ms
コンパイル使用メモリ 145,808 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-12 06:15:04
合計ジャッジ時間 2,553 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
  int n;
  cin >> n;
  
  vi a(n);
  rep(i, n) cin >> a[i];

  int ans = inf;
  for(int i = 1; i <= (n+1)/2; i++){
    for(int j = i-1; j <= n-i; j++){
      int pos = 0, neg = 0;
      rep(k, n){
        int need = max(0LL, i-abs(j-k));
        if(a[k] >= need) pos += a[k]-need;
        else neg += need-a[k];
      }

//      printf("%lld %lld %lld %lld\n", i, j, pos, neg);
      if(neg > pos) continue;
      ans = min(ans, pos);
    }
  }

  cout << ans << endl;

  return 0;
}
0