結果

問題 No.2094 Symmetry
ユーザー umezoumezo
提出日時 2022-10-07 22:40:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 786 bytes
コンパイル時間 2,347 ms
コンパイル使用メモリ 210,808 KB
実行使用メモリ 9,380 KB
最終ジャッジ日時 2023-09-03 14:08:12
合計ジャッジ時間 6,206 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,500 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 72 ms
9,164 KB
testcase_10 AC 73 ms
9,220 KB
testcase_11 AC 72 ms
9,236 KB
testcase_12 AC 72 ms
9,168 KB
testcase_13 AC 61 ms
7,344 KB
testcase_14 AC 72 ms
9,172 KB
testcase_15 AC 72 ms
9,168 KB
testcase_16 AC 72 ms
9,164 KB
testcase_17 AC 61 ms
7,448 KB
testcase_18 AC 61 ms
7,576 KB
testcase_19 AC 72 ms
9,232 KB
testcase_20 AC 72 ms
9,380 KB
testcase_21 AC 73 ms
9,240 KB
testcase_22 AC 72 ms
9,160 KB
testcase_23 AC 61 ms
7,400 KB
testcase_24 AC 61 ms
7,404 KB
testcase_25 AC 72 ms
9,180 KB
testcase_26 AC 71 ms
9,176 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 46 ms
9,240 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 48 ms
9,224 KB
testcase_31 AC 46 ms
9,176 KB
testcase_32 AC 48 ms
9,304 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 39 ms
9,180 KB
testcase_35 AC 34 ms
9,168 KB
testcase_36 AC 33 ms
7,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  ll n,k;
  cin>>n>>k;
  vector<string> S(2*n);
  rep(i,2*n) cin>>S[i];
  vector<vector<ll>> C(2*n,vector<ll>(2*n));
  vector<ll> A;
  int cnt=0;
  rep(i,2*n) rep(j,2*n){
    cin>>C[i][j];
    A.push_back(C[i][j]);
    if(S[i][j]=='#') cnt++;
  }
  sort(ALL(A));
  reverse(ALL(A));
  
  ll ans=0;
  rep(i,cnt) ans+=A[i];
  
  if(cnt%2==0){
    vector<ll> B;
    rep(i,2*n) rep(j,n) B.push_back(C[i][j]+C[i][2*n-1-j]);
    sort(ALL(B));
    reverse(ALL(B));
    ll tmp=k;
    rep(i,cnt/2) tmp+=B[i];
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
  
  return 0;
}
0