結果

問題 No.2094 Symmetry
ユーザー 259_Momone259_Momone
提出日時 2022-10-07 21:46:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 992 bytes
コンパイル時間 4,678 ms
コンパイル使用メモリ 265,380 KB
実行使用メモリ 10,164 KB
最終ジャッジ日時 2023-09-03 01:18:26
合計ジャッジ時間 9,156 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 139 ms
9,920 KB
testcase_10 AC 137 ms
9,972 KB
testcase_11 AC 137 ms
10,028 KB
testcase_12 AC 136 ms
9,972 KB
testcase_13 AC 126 ms
8,968 KB
testcase_14 AC 137 ms
9,920 KB
testcase_15 AC 136 ms
9,956 KB
testcase_16 AC 136 ms
9,968 KB
testcase_17 AC 127 ms
8,976 KB
testcase_18 AC 127 ms
8,972 KB
testcase_19 AC 136 ms
9,920 KB
testcase_20 AC 137 ms
10,164 KB
testcase_21 AC 137 ms
9,968 KB
testcase_22 AC 137 ms
9,912 KB
testcase_23 AC 126 ms
8,916 KB
testcase_24 AC 126 ms
8,908 KB
testcase_25 AC 137 ms
9,924 KB
testcase_26 AC 137 ms
9,928 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 114 ms
10,028 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 122 ms
9,960 KB
testcase_31 AC 114 ms
10,024 KB
testcase_32 AC 123 ms
9,956 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 87 ms
10,016 KB
testcase_35 AC 72 ms
9,956 KB
testcase_36 AC 65 ms
8,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>

int main() {
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned long> s(4 * N * N);
    for(unsigned long i{}; i < 2 * N; ++i){
        string S;
        cin >> S;
        transform(begin(S), end(S), begin(s) + 2 * i * N, [](auto c){return c == '#';});
    }
    unsigned long S{reduce(begin(s), end(s))};
    vector<long> C(4 * N * N);
    for(auto&& c : C)cin >> c;
    vector<long> sorted_c(C);
    sort(begin(sorted_c), end(sorted_c), greater<>{});
    long ans{reduce(begin(sorted_c), begin(sorted_c) + S)};
    if(~S & 1){
        vector<long> symmetric_c(2 * N * N);
        for(unsigned long i{}; i < 2 * N; ++i)for(unsigned long j{}; j < N; ++j)symmetric_c[i * N + j] = C[2 * i * N + j] + C[2 * i * N + 2 * N - 1 - j];
        sort(begin(symmetric_c), end(symmetric_c), greater<>{});
        ans = max<long>(ans, reduce(begin(symmetric_c), begin(symmetric_c) + S / 2) + K);
    }
    cout << ans << endl;
    return 0;
}
0