結果

問題 No.2094 Symmetry
ユーザー rogi52rogi52
提出日時 2022-10-07 21:46:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,000 bytes
コンパイル時間 2,097 ms
コンパイル使用メモリ 207,896 KB
最終ジャッジ日時 2025-02-07 23:08:01
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    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));
    rep(i,2*N)rep(j,2*N) cin >> C[i][j];

    int cntB = 0;
    rep(i,2*N)rep(j,2*N) if(S[i][j] == '#') cntB++;
    ll ans1 = [N, C, cntB]() {
        vector<ll> V;
        rep(i,2*N)rep(j,2*N) V.push_back(C[i][j]);
        sort(V.rbegin(), V.rend());
        ll ans = 0;
        rep(i,cntB) ans += V[i];
        return ans;
    }();

    ll ans2 = [N, K, C, cntB]() {
        if(cntB % 2 == 1) return numeric_limits<ll>::min();
        vector<ll> V;
        rep(i,2*N)rep(j,N) V.push_back(C[i][j] + C[i][2 * N - 1 - j]);
        sort(V.rbegin(), V.rbegin());
        ll ans = 0;
        rep(i,cntB/2) ans += V[i];
        return ans + K;
    }();

    cout << max(ans1, ans2) << endl;
}
0