結果

問題 No.2094 Symmetry
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-05-05 18:06:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 1,110 bytes
コンパイル時間 1,397 ms
コンパイル使用メモリ 118,536 KB
実行使用メモリ 9,660 KB
最終ジャッジ日時 2023-08-15 00:36:18
合計ジャッジ時間 8,599 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 138 ms
9,656 KB
testcase_10 AC 140 ms
9,580 KB
testcase_11 AC 138 ms
9,656 KB
testcase_12 AC 138 ms
9,576 KB
testcase_13 AC 138 ms
9,504 KB
testcase_14 AC 139 ms
9,636 KB
testcase_15 AC 138 ms
9,584 KB
testcase_16 AC 137 ms
9,592 KB
testcase_17 AC 138 ms
9,524 KB
testcase_18 AC 139 ms
9,588 KB
testcase_19 AC 140 ms
9,548 KB
testcase_20 AC 140 ms
9,660 KB
testcase_21 AC 139 ms
9,524 KB
testcase_22 AC 138 ms
9,584 KB
testcase_23 AC 138 ms
9,580 KB
testcase_24 AC 137 ms
9,572 KB
testcase_25 AC 137 ms
9,576 KB
testcase_26 AC 137 ms
9,500 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 116 ms
9,580 KB
testcase_29 AC 1 ms
4,384 KB
testcase_30 AC 122 ms
9,524 KB
testcase_31 AC 115 ms
9,576 KB
testcase_32 AC 123 ms
9,512 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 87 ms
9,656 KB
testcase_35 AC 71 ms
9,656 KB
testcase_36 AC 69 ms
9,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    ll N, K, cnt=0, ans=0, tot=0;
    cin >> N >> K;
    N *= 2;
    vector<ll> v1, v2;
    vector<string> S(N);
    vector<vector<ll>> C(N, vector<ll>(N));
    for (int i=0; i<N; i++){
        cin >> S[i];
        for (auto c : S[i]) if (c == '#') cnt++;
    }
    for (int i=0; i<N; i++){
        for (int j=0; j<N; j++){
            cin >> C[i][j];
            v1.push_back(C[i][j]);
        }
        for (int j=0; j<N/2; j++){
            v2.push_back(C[i][j]+C[i][N-1-j]);
        }
    }

    sort(v1.begin(), v1.end(), greater<ll>());
    sort(v2.begin(), v2.end(), greater<ll>());

    for (int i=0; i<cnt; i++) tot += v1[i];
    ans = tot;
    if (cnt % 2 == 0){
        cnt /= 2;
        tot = 0;
        for (int i=0; i<cnt; i++) tot += v2[i];
        ans = max(ans, tot+K);
    }

    cout << ans << endl;

    return 0;
}
0