結果

問題 No.2094 Symmetry
ユーザー HaaHaa
提出日時 2022-10-07 21:43:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 1,115 bytes
コンパイル時間 1,802 ms
コンパイル使用メモリ 177,328 KB
実行使用メモリ 8,936 KB
最終ジャッジ日時 2023-09-03 01:06:25
合計ジャッジ時間 7,027 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 140 ms
8,812 KB
testcase_10 AC 140 ms
8,676 KB
testcase_11 AC 141 ms
8,808 KB
testcase_12 AC 140 ms
8,676 KB
testcase_13 AC 129 ms
7,656 KB
testcase_14 AC 140 ms
8,672 KB
testcase_15 AC 141 ms
8,672 KB
testcase_16 AC 141 ms
8,784 KB
testcase_17 AC 129 ms
7,668 KB
testcase_18 AC 130 ms
7,604 KB
testcase_19 AC 141 ms
8,672 KB
testcase_20 AC 140 ms
8,780 KB
testcase_21 AC 142 ms
8,780 KB
testcase_22 AC 141 ms
8,792 KB
testcase_23 AC 129 ms
7,600 KB
testcase_24 AC 129 ms
7,656 KB
testcase_25 AC 140 ms
8,720 KB
testcase_26 AC 140 ms
8,808 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 119 ms
8,728 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 127 ms
8,724 KB
testcase_31 AC 119 ms
8,724 KB
testcase_32 AC 130 ms
8,664 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 90 ms
8,936 KB
testcase_35 AC 75 ms
8,672 KB
testcase_36 AC 68 ms
7,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;};
constexpr ll MOD=998244353;
constexpr ll INF=2e18;

int main(){
    ll n, k; cin >> n >> k;
    ll m=n*2;
    vector<string> s(m);
    REP(i,m) cin >> s[i];
    VVI c(m,VI(m));
    REP(i,m)REP(j,m) cin >> c[i][j];
    ll cnt=0;
    REP(i,m)REP(j,m){
        if(s[i][j]=='#')
            cnt++;
    }
    ll ans=-INF;
    if(cnt%2==0){
        VI a;
        REP(i,m)REP(j,n){
            a.push_back(c[i][j]+c[i][m-1-j]);
        }
        sort(ALL(a),greater<ll>());
        ll sum=k;
        REP(i,cnt/2) sum+=a[i];
        chmax(ans,sum);
    }
    VI b;
    REP(i,m)REP(j,m) b.push_back(c[i][j]);
    sort(ALL(b),greater<ll>());
    ll sum=0;
    REP(i,cnt) sum+=b[i];
    chmax(ans,sum);
    cout << ans << endl;
    return 0;
}
0