結果

問題 No.2094 Symmetry
ユーザー t98slidert98slider
提出日時 2022-10-07 23:05:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 944 bytes
コンパイル時間 1,722 ms
コンパイル使用メモリ 175,348 KB
実行使用メモリ 8,528 KB
最終ジャッジ日時 2023-09-03 15:09:02
合計ジャッジ時間 5,391 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 69 ms
8,328 KB
testcase_10 AC 68 ms
8,332 KB
testcase_11 AC 68 ms
8,380 KB
testcase_12 AC 68 ms
8,528 KB
testcase_13 AC 68 ms
8,308 KB
testcase_14 AC 68 ms
8,284 KB
testcase_15 AC 69 ms
8,388 KB
testcase_16 AC 68 ms
8,312 KB
testcase_17 AC 68 ms
8,332 KB
testcase_18 AC 68 ms
8,328 KB
testcase_19 AC 68 ms
8,308 KB
testcase_20 AC 68 ms
8,316 KB
testcase_21 AC 68 ms
8,336 KB
testcase_22 AC 68 ms
8,312 KB
testcase_23 AC 68 ms
8,308 KB
testcase_24 AC 68 ms
8,332 KB
testcase_25 AC 68 ms
8,324 KB
testcase_26 AC 68 ms
8,312 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 44 ms
8,324 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 45 ms
8,300 KB
testcase_31 AC 43 ms
8,308 KB
testcase_32 AC 45 ms
8,284 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 35 ms
8,468 KB
testcase_35 AC 31 ms
8,308 KB
testcase_36 AC 34 ms
8,292 KB
権限があれば一括ダウンロードができます

ソースコード

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