結果
問題 | No.1345 Beautiful BINGO |
ユーザー | chineristAC |
提出日時 | 2021-01-16 13:29:13 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,282 bytes |
コンパイル時間 | 152 ms |
コンパイル使用メモリ | 81,768 KB |
実行使用メモリ | 82,712 KB |
最終ジャッジ日時 | 2024-11-27 13:54:20 |
合計ジャッジ時間 | 36,438 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
52,608 KB |
testcase_01 | AC | 42 ms
58,880 KB |
testcase_02 | AC | 43 ms
59,136 KB |
testcase_03 | AC | 37 ms
52,864 KB |
testcase_04 | AC | 36 ms
52,608 KB |
testcase_05 | AC | 52 ms
65,792 KB |
testcase_06 | AC | 36 ms
52,736 KB |
testcase_07 | AC | 87 ms
76,800 KB |
testcase_08 | AC | 36 ms
52,352 KB |
testcase_09 | AC | 37 ms
52,736 KB |
testcase_10 | AC | 43 ms
60,928 KB |
testcase_11 | AC | 51 ms
66,304 KB |
testcase_12 | AC | 37 ms
52,608 KB |
testcase_13 | AC | 92 ms
76,604 KB |
testcase_14 | AC | 48 ms
63,432 KB |
testcase_15 | AC | 37 ms
51,968 KB |
testcase_16 | AC | 43 ms
61,056 KB |
testcase_17 | AC | 40 ms
58,716 KB |
testcase_18 | AC | 36 ms
52,224 KB |
testcase_19 | AC | 40 ms
58,728 KB |
testcase_20 | AC | 36 ms
52,224 KB |
testcase_21 | AC | 40 ms
58,624 KB |
testcase_22 | AC | 251 ms
79,284 KB |
testcase_23 | AC | 1,499 ms
81,816 KB |
testcase_24 | AC | 796 ms
78,808 KB |
testcase_25 | AC | 192 ms
77,656 KB |
testcase_26 | AC | 482 ms
78,716 KB |
testcase_27 | AC | 1,474 ms
81,928 KB |
testcase_28 | AC | 177 ms
77,660 KB |
testcase_29 | AC | 478 ms
78,724 KB |
testcase_30 | AC | 263 ms
77,520 KB |
testcase_31 | AC | 256 ms
78,896 KB |
testcase_32 | AC | 135 ms
77,928 KB |
testcase_33 | AC | 1,540 ms
81,276 KB |
testcase_34 | AC | 152 ms
78,904 KB |
testcase_35 | AC | 166 ms
78,896 KB |
testcase_36 | TLE | - |
testcase_37 | AC | 156 ms
78,504 KB |
testcase_38 | AC | 544 ms
79,800 KB |
testcase_39 | AC | 1,505 ms
81,180 KB |
testcase_40 | AC | 838 ms
81,408 KB |
testcase_41 | AC | 884 ms
79,960 KB |
testcase_42 | AC | 35 ms
52,352 KB |
testcase_43 | AC | 36 ms
52,352 KB |
testcase_44 | AC | 41 ms
59,136 KB |
testcase_45 | AC | 40 ms
58,880 KB |
testcase_46 | AC | 36 ms
52,096 KB |
testcase_47 | AC | 34 ms
52,340 KB |
testcase_48 | AC | 34 ms
52,608 KB |
testcase_49 | AC | 34 ms
52,352 KB |
testcase_50 | AC | 35 ms
52,224 KB |
testcase_51 | AC | 39 ms
58,496 KB |
testcase_52 | AC | 1,508 ms
81,408 KB |
testcase_53 | AC | 1,487 ms
80,792 KB |
testcase_54 | AC | 1,545 ms
81,796 KB |
testcase_55 | AC | 1,681 ms
81,976 KB |
testcase_56 | AC | 1,551 ms
81,556 KB |
testcase_57 | AC | 1,564 ms
81,680 KB |
testcase_58 | AC | 1,633 ms
81,700 KB |
testcase_59 | AC | 1,659 ms
81,920 KB |
testcase_60 | TLE | - |
testcase_61 | AC | 1,692 ms
82,712 KB |
testcase_62 | AC | 1,599 ms
81,044 KB |
ソースコード
N,M = map(int,input().split()) A = [list(map(int,input().split())) for i in range(N)] S = [sum(A[i]) for i in range(N)] tmp_A = [[A[i][j] for j in range(N)] for i in range(N)] def dfs(i,cost,cnt): res = 10**18 if i==N+2: column = [sum(tmp_A[k][j] for k in range(N)) for j in range(N)] column.sort() cost += sum(column[:cnt]) return cost elif i<N: tmp1 = dfs(i+1,cost,cnt) for j in range(N): tmp_A[i][j] = 0 cost += A[i][j] tmp2 = dfs(i+1,cost,cnt-1) for j in range(N): tmp_A[i][j] = A[i][j] return min(res,tmp1,tmp2) elif i==N: tmp1 = dfs(i+1,cost,cnt) memo = [tmp_A[j][j] for j in range(N)] for j in range(N): tmp_A[j][j] = 0 cost += memo[j] tmp2 = dfs(i+1,cost,cnt-1) for j in range(N): tmp_A[j][j] = memo[j] return min(res,tmp1,tmp2) else: tmp1 = dfs(i+1,cost,cnt) memo = [tmp_A[N-1-j][j] for j in range(N)] for j in range(N): tmp_A[N-1-j][j] = 0 cost += memo[j] tmp2 = dfs(i+1,cost,cnt-1) for j in range(N): tmp_A[N-1-j][j] = memo[j] return min(res,tmp1,tmp2) print(dfs(0,0,M))