結果

問題 No.2094 Symmetry
ユーザー tamatotamato
提出日時 2022-10-07 21:31:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 860 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 105,148 KB
最終ジャッジ日時 2023-09-03 00:26:36
合計ジャッジ時間 7,755 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,448 KB
testcase_01 AC 68 ms
71,176 KB
testcase_02 AC 67 ms
71,264 KB
testcase_03 AC 67 ms
71,452 KB
testcase_04 AC 69 ms
71,016 KB
testcase_05 AC 68 ms
71,336 KB
testcase_06 AC 68 ms
71,404 KB
testcase_07 AC 68 ms
71,392 KB
testcase_08 AC 68 ms
71,176 KB
testcase_09 AC 203 ms
97,196 KB
testcase_10 AC 203 ms
100,796 KB
testcase_11 AC 199 ms
96,992 KB
testcase_12 AC 200 ms
96,668 KB
testcase_13 AC 169 ms
94,028 KB
testcase_14 AC 198 ms
102,628 KB
testcase_15 AC 199 ms
102,204 KB
testcase_16 AC 199 ms
96,948 KB
testcase_17 AC 164 ms
94,060 KB
testcase_18 AC 170 ms
93,416 KB
testcase_19 AC 200 ms
98,668 KB
testcase_20 AC 204 ms
102,380 KB
testcase_21 AC 196 ms
98,496 KB
testcase_22 AC 198 ms
96,976 KB
testcase_23 AC 166 ms
94,172 KB
testcase_24 AC 174 ms
97,056 KB
testcase_25 AC 197 ms
102,820 KB
testcase_26 AC 197 ms
102,716 KB
testcase_27 AC 67 ms
71,204 KB
testcase_28 AC 128 ms
96,704 KB
testcase_29 AC 67 ms
71,280 KB
testcase_30 AC 134 ms
103,328 KB
testcase_31 AC 136 ms
96,564 KB
testcase_32 AC 135 ms
104,604 KB
testcase_33 AC 73 ms
71,528 KB
testcase_34 AC 133 ms
105,016 KB
testcase_35 AC 134 ms
105,148 KB
testcase_36 AC 118 ms
97,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())
    G = []
    for _ in range(N * 2):
        G.append(input().rstrip('\n'))
    C = []
    for _ in range(2*N):
        C.append(list(map(int, input().split())))

    cnt = 0
    A = []
    for h in range(2*N):
        for w in range(2*N):
            A.append(C[h][w])
            if G[h][w] == "#":
                cnt += 1
    A.sort(reverse=True)
    ans = 0
    for i in range(cnt):
        ans += A[i]
    
    if cnt & 1 == 0:
        B = []
        for h in range(2*N):
            for w in range(N):
                B.append(C[h][w] + C[h][-w-1])
        ans2 = K
        B.sort(reverse=True)
        for i in range(cnt // 2):
            ans2 += B[i]
        ans = max(ans, ans2)
    print(ans)


if __name__ == '__main__':
    main()
0