結果

問題 No.2094 Symmetry
ユーザー ygd.ygd.
提出日時 2022-10-07 23:20:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 1,245 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 110,636 KB
最終ジャッジ日時 2023-09-03 15:41:06
合計ジャッジ時間 9,159 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
72,152 KB
testcase_01 AC 98 ms
72,532 KB
testcase_02 AC 99 ms
72,200 KB
testcase_03 AC 99 ms
72,108 KB
testcase_04 AC 98 ms
72,528 KB
testcase_05 AC 100 ms
72,100 KB
testcase_06 AC 97 ms
72,304 KB
testcase_07 AC 100 ms
72,480 KB
testcase_08 AC 103 ms
72,256 KB
testcase_09 AC 244 ms
109,792 KB
testcase_10 AC 238 ms
109,360 KB
testcase_11 AC 244 ms
110,432 KB
testcase_12 AC 243 ms
110,268 KB
testcase_13 AC 206 ms
100,504 KB
testcase_14 AC 239 ms
110,148 KB
testcase_15 AC 239 ms
110,328 KB
testcase_16 AC 242 ms
109,948 KB
testcase_17 AC 218 ms
100,736 KB
testcase_18 AC 207 ms
100,252 KB
testcase_19 AC 240 ms
110,280 KB
testcase_20 AC 235 ms
110,500 KB
testcase_21 AC 239 ms
110,636 KB
testcase_22 AC 242 ms
109,556 KB
testcase_23 AC 216 ms
100,844 KB
testcase_24 AC 208 ms
100,436 KB
testcase_25 AC 238 ms
110,036 KB
testcase_26 AC 238 ms
110,048 KB
testcase_27 AC 99 ms
72,112 KB
testcase_28 AC 170 ms
105,876 KB
testcase_29 AC 104 ms
72,116 KB
testcase_30 AC 167 ms
105,752 KB
testcase_31 AC 171 ms
108,592 KB
testcase_32 AC 172 ms
108,836 KB
testcase_33 AC 101 ms
72,524 KB
testcase_34 AC 173 ms
104,652 KB
testcase_35 AC 175 ms
107,160 KB
testcase_36 AC 163 ms
100,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
import math
import bisect
#import itertools
#import random
from heapq import heapify, heappop, heappush
from collections import defaultdict 
#from collections import deque
import copy #DeepCopy: hoge = [_[:] for _ in hogehoge]
#from functools import lru_cache
#@lru_cache(maxsize=None)
MOD = pow(10,9) + 7
#MOD = 998244353
#dx = [1,0,-1,0]
#dy = [0,1,0,-1]
#dx8 = [1,1,0,-1,-1,-1,0,1]
#dy8 = [0,1,1,1,0,-1,-1,-1]

def main():
    N,K = map(int,input().split())
    N2 = N * 2
    S = [str(input()) for _ in range(N2)]
    C = [list(map(int,input().split())) for _ in range(N2)]

    black = 0
    L = []
    for i in range(N2):
        for j in range(N2):
            L.append(C[i][j])
            if S[i][j] == '#':
                black += 1
    L.sort(reverse=True)
    ans = sum(L[:black])

    if black%2 == 1:
        print(ans);exit()
    
    L = []
    for i in range(N2):
        for j in range(N):
            temp = C[i][j] + C[i][N2-1-j]
            L.append(temp)
    L.sort(reverse=True)

    tans = sum(L[:(black//2)]) + K
    ans = max(ans, tans)

    print(ans)


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