結果

問題 No.2094 Symmetry
ユーザー t98slidert98slider
提出日時 2022-10-07 23:05:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 944 bytes
コンパイル時間 1,701 ms
コンパイル使用メモリ 179,352 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2024-06-12 20:52:00
合計ジャッジ時間 4,629 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k, cnt = 0, idx1 = 0, idx2 = 0;
    cin >> n >> k;
    vector<string> A(2 * n);
    vector<vector<ll>> C(2 * n, vector<ll>(2 * n));
    vector<ll> c1(4 * n * n), c2(2 * n * n);
    for(auto &&s:A){
        cin >> s;
        cnt += count(s.begin(), s.end(), '#');
    }
    for(int y = 0; y < 2 * n; y++){
        for(int x = 0; x < 2 * n; x++){
            cin >> C[y][x];
            c1[idx1++] = C[y][x];
        }
        for(int x = 0; x < n; x++){
            c2[idx2++] = C[y][x] + C[y][2 * n - 1 - x];
        }
    }
    sort(c1.rbegin(), c1.rend());
    sort(c2.rbegin(), c2.rend());
    ll ans = -(1ll << 60);
    if(cnt % 2 == 0)ans = max(ans, accumulate(c2.begin(), c2.begin() + cnt / 2, 0ll) + k);
    ans = max(ans, accumulate(c1.begin(), c1.begin() + cnt, 0ll));
    cout << ans << '\n';
}
0