結果

問題 No.77 レンガのピラミッド
ユーザー CleyLCleyL
提出日時 2020-03-07 19:52:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 563 bytes
コンパイル時間 831 ms
コンパイル使用メモリ 69,112 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 14:16:36
合計ジャッジ時間 1,376 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> A(n);
  for(int i = 0; n > i; i++){
    cin>>A[i];
  }
  int ans = 10000000;
  for(int i = 0; n > i; i++){
    for(int j = i; n > j; j+=2){
      //i~j;
      int p = 0;
      int t = 0;
      for(int z = 0; n > z; z++){
        if(A[z]>max(0,1+min(z-i,j-z))){
          p+=A[z]-max(0,1+min(z-i,j-z));
        }else{
          t+=max(0,1+min(z-i,j-z))-A[z];
        }
      }
      if(p >= t){
        ans = min(ans,p);
      }
    }
  }
  cout << ans << endl;
}
0