結果

問題 No.2094 Symmetry
ユーザー rogi52rogi52
提出日時 2022-10-07 21:48:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 998 bytes
コンパイル時間 2,299 ms
コンパイル使用メモリ 212,460 KB
実行使用メモリ 9,924 KB
最終ジャッジ日時 2023-09-03 01:23:04
合計ジャッジ時間 5,978 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 73 ms
9,668 KB
testcase_10 AC 72 ms
9,732 KB
testcase_11 AC 73 ms
9,612 KB
testcase_12 AC 73 ms
9,620 KB
testcase_13 AC 61 ms
9,440 KB
testcase_14 AC 73 ms
9,604 KB
testcase_15 AC 73 ms
9,616 KB
testcase_16 AC 73 ms
9,736 KB
testcase_17 AC 61 ms
9,444 KB
testcase_18 AC 61 ms
9,380 KB
testcase_19 AC 72 ms
9,736 KB
testcase_20 AC 73 ms
9,608 KB
testcase_21 AC 73 ms
9,616 KB
testcase_22 AC 73 ms
9,620 KB
testcase_23 AC 61 ms
9,384 KB
testcase_24 AC 61 ms
9,388 KB
testcase_25 AC 72 ms
9,604 KB
testcase_26 AC 72 ms
9,916 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 47 ms
9,616 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 49 ms
9,620 KB
testcase_31 AC 48 ms
9,676 KB
testcase_32 AC 50 ms
9,616 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 40 ms
9,924 KB
testcase_35 AC 35 ms
9,796 KB
testcase_36 AC 36 ms
9,388 KB
権限があれば一括ダウンロードができます

ソースコード

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.rend());
        ll ans = 0;
        rep(i,cntB/2) ans += V[i];
        return ans + K;
    }();

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