結果

問題 No.2094 Symmetry
ユーザー mkawa2mkawa2
提出日時 2022-10-07 21:43:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 1,083 bytes
コンパイル時間 427 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 105,076 KB
最終ジャッジ日時 2023-09-03 01:05:52
合計ジャッジ時間 7,817 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,636 KB
testcase_01 AC 74 ms
71,524 KB
testcase_02 AC 72 ms
71,236 KB
testcase_03 AC 72 ms
71,296 KB
testcase_04 AC 74 ms
71,472 KB
testcase_05 AC 74 ms
71,128 KB
testcase_06 AC 75 ms
71,408 KB
testcase_07 AC 73 ms
71,120 KB
testcase_08 AC 72 ms
71,564 KB
testcase_09 AC 196 ms
97,856 KB
testcase_10 AC 194 ms
99,800 KB
testcase_11 AC 196 ms
98,192 KB
testcase_12 AC 193 ms
98,116 KB
testcase_13 AC 167 ms
96,852 KB
testcase_14 AC 195 ms
98,352 KB
testcase_15 AC 195 ms
98,736 KB
testcase_16 AC 195 ms
97,928 KB
testcase_17 AC 170 ms
96,884 KB
testcase_18 AC 168 ms
96,652 KB
testcase_19 AC 197 ms
100,308 KB
testcase_20 AC 198 ms
100,168 KB
testcase_21 AC 195 ms
100,272 KB
testcase_22 AC 194 ms
97,860 KB
testcase_23 AC 166 ms
97,200 KB
testcase_24 AC 167 ms
97,220 KB
testcase_25 AC 196 ms
99,400 KB
testcase_26 AC 193 ms
97,804 KB
testcase_27 AC 72 ms
71,460 KB
testcase_28 AC 131 ms
97,788 KB
testcase_29 AC 73 ms
71,352 KB
testcase_30 AC 127 ms
94,912 KB
testcase_31 AC 128 ms
97,136 KB
testcase_32 AC 129 ms
96,676 KB
testcase_33 AC 72 ms
71,544 KB
testcase_34 AC 128 ms
105,024 KB
testcase_35 AC 131 ms
105,076 KB
testcase_36 AC 122 ms
98,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

n, k = LI()
n2 = n*2
cnt = sum(SI().count("#") for _ in range(n2))
cc = LLI(n2)

dd = []
for c in cc: dd += c
dd.sort(reverse=True)
ans = sum(dd[:cnt])

if cnt & 1 == 0:
    dd = []
    for i in range(n2):
        for j in range(n):
            dd.append(cc[i][j]+cc[i][n2-1-j])
    dd.sort(reverse=True)
    ans = max(ans, sum(dd[:cnt//2])+k)

print(ans)
    
0