結果
問題 |
No.957 植林
|
ユーザー |
![]() |
提出日時 | 2025-06-12 21:34:01 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 929 bytes |
コンパイル時間 | 233 ms |
コンパイル使用メモリ | 82,208 KB |
実行使用メモリ | 93,532 KB |
最終ジャッジ日時 | 2025-06-12 21:34:50 |
合計ジャッジ時間 | 4,611 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | TLE * 1 -- * 44 |
ソースコード
def main(): import sys input = sys.stdin.read().split() ptr = 0 H = int(input[ptr]); ptr +=1 W = int(input[ptr]); ptr +=1 G = [] for _ in range(H): row = list(map(int, input[ptr:ptr+W])) ptr += W G.append(row) R = list(map(int, input[ptr:ptr+H])) ptr += H C = list(map(int, input[ptr:ptr+W])) ptr += W a = [R[i] - sum(G[i]) for i in range(H)] b = [C[j] - sum([G[i][j] for i in range(H)]) for j in range(W)] c = G max_total = 0 for mask in range(1 << H): row_selected = [i for i in range(H) if (mask >> i) & 1] a_sum = sum(a[i] for i in row_selected) current_b = [b[j] + sum(c[i][j] for i in row_selected) for j in range(W)] total = a_sum + sum(max(0, current_b[j]) for j in range(W)) if total > max_total: max_total = total print(max_total) if __name__ == '__main__': main()