結果

問題 No.2094 Symmetry
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2022-10-07 21:47:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 875 bytes
コンパイル時間 2,507 ms
コンパイル使用メモリ 200,948 KB
実行使用メモリ 4,804 KB
最終ジャッジ日時 2023-09-03 01:23:19
合計ジャッジ時間 9,475 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 2 ms
4,376 KB
testcase_28 RE -
testcase_29 AC 2 ms
4,376 KB
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 AC 2 ms
4,380 KB
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main () {
    int N;
    ll K;
    cin >> N >> K;
    N *= 2;
    int b = 0;
    for (int i = 0; i < N * N; i ++) {
        char c;
        cin >> c;
        b += (c == '#');
    }
    ll C1[90000];
    for (int i = 0; i < N * N; i ++) {
        cin >> C1[i];
    }
    ll C2[90000];
    for (int i = 0; i < (N * N) / 2; i ++) {
        int p = i / (N / 2), q = i % (N / 2);
        C2[i] = C1[p * N + q] + C1[p * N + N - q - 1];
    }
    sort(C1, C1 + (N * N));
    sort(C2, C2 + (N * N / 2));
    ll ans1 = 0;
    for (int i = 0; i < b; i ++) {
        ans1 += C1[N * N - 1 - i];
    }
    if (b % 2) {
        cout << ans1 << endl;
        return 0;
    }
    ll ans2 = 0;
    for (int i = 0; i < b / 2; i ++) {
        ans2 += C2[N * N / 2 - 1 - i];
    }
    cout << max(ans1, ans2 + K) << endl;
}
0