結果

問題 No.2094 Symmetry
ユーザー baLoon8128baLoon8128
提出日時 2022-10-07 21:45:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 1,018 bytes
コンパイル時間 4,126 ms
コンパイル使用メモリ 229,840 KB
実行使用メモリ 6,304 KB
最終ジャッジ日時 2023-09-03 01:13:11
合計ジャッジ時間 9,643 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 141 ms
6,200 KB
testcase_10 AC 142 ms
6,200 KB
testcase_11 AC 143 ms
6,180 KB
testcase_12 AC 143 ms
6,152 KB
testcase_13 AC 131 ms
5,132 KB
testcase_14 AC 142 ms
6,200 KB
testcase_15 AC 142 ms
6,200 KB
testcase_16 AC 143 ms
6,292 KB
testcase_17 AC 131 ms
5,324 KB
testcase_18 AC 131 ms
5,112 KB
testcase_19 AC 142 ms
6,160 KB
testcase_20 AC 143 ms
6,172 KB
testcase_21 AC 143 ms
6,156 KB
testcase_22 AC 143 ms
6,304 KB
testcase_23 AC 132 ms
5,120 KB
testcase_24 AC 132 ms
5,324 KB
testcase_25 AC 141 ms
6,136 KB
testcase_26 AC 142 ms
6,304 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 116 ms
6,116 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 124 ms
6,144 KB
testcase_31 AC 117 ms
6,136 KB
testcase_32 AC 124 ms
6,204 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 88 ms
6,304 KB
testcase_35 AC 74 ms
6,296 KB
testcase_36 AC 68 ms
5,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repr(i, n) for (int i = (int)(n - 1); i >= 0; --i)

int main() {
    int n;
    ll K;
    cin >> n >> K;
    n *= 2;
    int cnt = 0;
    rep(i, n) rep(j, n) {
        char ch;
        cin >> ch;
        if (ch == '#') cnt++;
    }
    vvi c(n, vi(n));
    rep(i, n) rep(j, n) cin >> c[i][j];

    ll ret = 0;
    vi s;
    rep(i, n) rep(j, n) s.push_back(c[i][j]);
    sort(s.begin(), s.end(), greater<int>());
    rep(k, cnt) ret += s[k];
    if (~cnt & 1) {
        vi t;
        rep(i, n) rep(j, n / 2) t.push_back(c[i][j] + c[i][n - 1 - j]);
        sort(t.begin(), t.end(), greater<int>());
        ll tmp = K;
        rep(k, cnt / 2) tmp += t[k];
        ret = max(ret, tmp);
    }
    cout << ret << endl;
    return 0;
}
0