結果

問題 No.1345 Beautiful BINGO
ユーザー aaaaaaaaaa2230
提出日時 2021-01-16 17:33:26
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 822 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 148,736 KB
最終ジャッジ日時 2024-11-27 21:49:04
合計ジャッジ時間 41,083 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13 RE * 36 TLE * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import deepcopy
n,m = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]

ans = 10**10
for i in range(1<<(n+2)):

    s = deepcopy(A)
    count = 0
    c = 0
    for j in range(n+2):
        if i >> j & 1:
            c += 1
            if j == n:
                for k in range(n):
                    count += s[k][k]
                    s[k][k] = 0
            elif j == n+1:
                for k in range(n):
                    count += s[k][-1-k]
                    s[k][-1-k] = 0
            else:
                for k in range(n):
                    count += s[k][j]
                    s[k][j] = 0
    l = [sum(s[i]) for i in range(n)]
    l.sort()
    now = 0
    while c < m:
        c += 1
        count += l[now]
        now += 1
    ans = min(ans,count)

print(ans)
0