結果

問題 No.1345 Beautiful BINGO
ユーザー rlangevinrlangevin
提出日時 2023-03-03 08:56:55
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 991 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 81,680 KB
実行使用メモリ 76,752 KB
最終ジャッジ日時 2023-10-18 00:50:29
合計ジャッジ時間 41,884 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,356 KB
testcase_01 AC 39 ms
53,356 KB
testcase_02 AC 37 ms
53,356 KB
testcase_03 AC 37 ms
53,356 KB
testcase_04 AC 36 ms
53,356 KB
testcase_05 AC 73 ms
73,300 KB
testcase_06 AC 37 ms
53,356 KB
testcase_07 AC 82 ms
75,956 KB
testcase_08 AC 38 ms
53,356 KB
testcase_09 AC 39 ms
53,356 KB
testcase_10 AC 52 ms
64,120 KB
testcase_11 AC 75 ms
73,896 KB
testcase_12 AC 38 ms
53,356 KB
testcase_13 AC 82 ms
75,956 KB
testcase_14 AC 53 ms
64,144 KB
testcase_15 AC 37 ms
53,356 KB
testcase_16 AC 53 ms
64,144 KB
testcase_17 AC 39 ms
53,356 KB
testcase_18 AC 37 ms
53,356 KB
testcase_19 AC 38 ms
53,356 KB
testcase_20 AC 37 ms
53,356 KB
testcase_21 AC 39 ms
53,356 KB
testcase_22 AC 176 ms
75,872 KB
testcase_23 TLE -
testcase_24 AC 1,023 ms
76,028 KB
testcase_25 AC 129 ms
76,024 KB
testcase_26 AC 504 ms
76,008 KB
testcase_27 TLE -
testcase_28 AC 128 ms
76,020 KB
testcase_29 AC 505 ms
75,912 KB
testcase_30 AC 303 ms
75,844 KB
testcase_31 AC 184 ms
76,088 KB
testcase_32 AC 91 ms
75,932 KB
testcase_33 TLE -
testcase_34 AC 101 ms
75,904 KB
testcase_35 AC 102 ms
75,904 KB
testcase_36 AC 675 ms
76,156 KB
testcase_37 AC 58 ms
68,324 KB
testcase_38 AC 507 ms
75,972 KB
testcase_39 TLE -
testcase_40 AC 1,027 ms
76,268 KB
testcase_41 AC 537 ms
76,024 KB
testcase_42 AC 37 ms
53,356 KB
testcase_43 AC 38 ms
53,356 KB
testcase_44 AC 39 ms
53,356 KB
testcase_45 AC 39 ms
53,356 KB
testcase_46 AC 38 ms
53,356 KB
testcase_47 AC 37 ms
53,356 KB
testcase_48 AC 38 ms
53,356 KB
testcase_49 AC 37 ms
53,356 KB
testcase_50 AC 38 ms
53,356 KB
testcase_51 AC 39 ms
53,356 KB
testcase_52 AC 100 ms
75,648 KB
testcase_53 TLE -
testcase_54 TLE -
testcase_55 TLE -
testcase_56 AC 99 ms
75,648 KB
testcase_57 TLE -
testcase_58 TLE -
testcase_59 TLE -
testcase_60 AC 1,077 ms
76,100 KB
testcase_61 TLE -
testcase_62 AC 86 ms
75,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def popcount(n):
    cnt = 0
    while n:
        cnt += n & 1
        n >>= 1
    return cnt

N, M = map(int, input().split())
A = []
for i in range(N):
    A.append(list(map(int, input().split())))

ans = 10 ** 18
for s in range(1 << (N + 2)):
    c = popcount(s)
    if c > M:
        continue
    seen = [[0] * N for i in range(N)]
    cnt = 0
    for i in range(N):
        for j in range(N):
            if (s >> i) & 1:
                seen[i][j] = 1
                cnt += A[i][j]
                continue
            if (s >> N) & 1 and i == j:
                seen[i][j] = 1
                cnt += A[i][j]
                continue
            if (s >> (N + 1)) & 1 and i + j == N - 1:
                seen[i][j] = 1
                cnt += A[i][j]
                continue
    L = [0] * N
    for i in range(N):
        for j in range(N):
            if seen[i][j]:
                continue
            L[j] += A[i][j]
    L.sort()
    ans = min(ans, cnt + sum(L[:M-c]))

print(ans)
0