結果

問題 No.1345 Beautiful BINGO
ユーザー titiatitia
提出日時 2021-01-18 08:46:53
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 953 bytes
コンパイル時間 789 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 78,216 KB
最終ジャッジ日時 2023-08-20 15:51:13
合計ジャッジ時間 27,616 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
70,888 KB
testcase_01 AC 60 ms
71,000 KB
testcase_02 AC 58 ms
71,268 KB
testcase_03 AC 58 ms
71,232 KB
testcase_04 AC 58 ms
71,140 KB
testcase_05 AC 89 ms
76,020 KB
testcase_06 AC 61 ms
71,020 KB
testcase_07 AC 96 ms
77,608 KB
testcase_08 AC 58 ms
70,924 KB
testcase_09 AC 58 ms
71,108 KB
testcase_10 AC 64 ms
76,140 KB
testcase_11 AC 70 ms
76,328 KB
testcase_12 AC 58 ms
71,144 KB
testcase_13 AC 97 ms
77,276 KB
testcase_14 AC 66 ms
71,276 KB
testcase_15 AC 61 ms
71,100 KB
testcase_16 AC 69 ms
76,032 KB
testcase_17 AC 59 ms
71,032 KB
testcase_18 AC 58 ms
71,256 KB
testcase_19 AC 58 ms
71,252 KB
testcase_20 AC 58 ms
71,260 KB
testcase_21 AC 57 ms
70,932 KB
testcase_22 AC 65 ms
76,372 KB
testcase_23 AC 104 ms
76,296 KB
testcase_24 AC 121 ms
77,588 KB
testcase_25 AC 122 ms
77,296 KB
testcase_26 AC 430 ms
77,316 KB
testcase_27 TLE -
testcase_28 AC 107 ms
77,420 KB
testcase_29 AC 388 ms
77,512 KB
testcase_30 AC 84 ms
76,528 KB
testcase_31 AC 111 ms
77,532 KB
testcase_32 AC 95 ms
77,344 KB
testcase_33 TLE -
testcase_34 AC 81 ms
76,500 KB
testcase_35 AC 94 ms
77,112 KB
testcase_36 AC 564 ms
77,168 KB
testcase_37 AC 91 ms
76,340 KB
testcase_38 AC 372 ms
77,968 KB
testcase_39 TLE -
testcase_40 AC 739 ms
77,676 KB
testcase_41 AC 412 ms
77,540 KB
testcase_42 AC 61 ms
71,292 KB
testcase_43 AC 64 ms
71,292 KB
testcase_44 AC 63 ms
71,256 KB
testcase_45 AC 61 ms
71,024 KB
testcase_46 AC 58 ms
70,964 KB
testcase_47 AC 62 ms
71,184 KB
testcase_48 AC 64 ms
71,244 KB
testcase_49 AC 63 ms
70,964 KB
testcase_50 AC 61 ms
71,288 KB
testcase_51 AC 60 ms
71,132 KB
testcase_52 AC 122 ms
76,772 KB
testcase_53 TLE -
testcase_54 AC 326 ms
77,444 KB
testcase_55 AC 756 ms
77,604 KB
testcase_56 AC 123 ms
76,812 KB
testcase_57 AC 1,948 ms
77,716 KB
testcase_58 AC 1,500 ms
78,008 KB
testcase_59 AC 1,987 ms
77,636 KB
testcase_60 AC 868 ms
77,384 KB
testcase_61 AC 1,035 ms
77,552 KB
testcase_62 AC 112 ms
76,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

ANS=1<<30
for i in range(1<<(N+2)):
    
    x=0
    for j in range(N+2):
        if (1<<j) & i !=0:
            x+=1

    r=M-x

    if r<0 or r>N:
        continue

    B=[[0]*N for j in range(N)]

    for j in range(N+2):
        if (1<<j) & i != 0:
            if j<N:
                for k in range(N):
                    B[k][j]=1
            elif j==N:
                for k in range(N):
                    B[k][k]=1
            else:
                for k in range(N):
                    B[k][N-k-1]=1

    SCORE=0
    C=[]

    for j in range(N):
        sc=0
        for k in range(N):
            if B[j][k]==1:
                SCORE+=A[j][k]
            else:
                sc+=A[j][k]
        C.append(sc)

    C.sort()

    ANS=min(ANS,SCORE+sum(C[:r]))

print(ANS)
    
            
            

    
        
0