結果

問題 No.1060 素敵な宝箱
ユーザー 草苺奶昔草苺奶昔
提出日時 2023-05-18 00:51:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 622 bytes
コンパイル時間 1,193 ms
コンパイル使用メモリ 87,320 KB
実行使用メモリ 83,916 KB
最終ジャッジ日時 2023-08-22 01:55:07
合計ジャッジ時間 7,230 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
80,376 KB
testcase_01 AC 156 ms
80,260 KB
testcase_02 AC 159 ms
80,268 KB
testcase_03 AC 158 ms
80,276 KB
testcase_04 AC 156 ms
80,308 KB
testcase_05 AC 156 ms
80,072 KB
testcase_06 AC 160 ms
80,292 KB
testcase_07 AC 160 ms
80,072 KB
testcase_08 AC 164 ms
81,156 KB
testcase_09 AC 164 ms
81,088 KB
testcase_10 AC 161 ms
81,144 KB
testcase_11 AC 159 ms
81,160 KB
testcase_12 AC 171 ms
83,532 KB
testcase_13 AC 175 ms
83,716 KB
testcase_14 AC 179 ms
83,700 KB
testcase_15 AC 174 ms
83,484 KB
testcase_16 AC 173 ms
83,640 KB
testcase_17 AC 170 ms
83,224 KB
testcase_18 AC 169 ms
83,644 KB
testcase_19 AC 167 ms
83,500 KB
testcase_20 AC 171 ms
83,756 KB
testcase_21 AC 171 ms
83,916 KB
testcase_22 AC 170 ms
83,812 KB
testcase_23 AC 171 ms
83,640 KB
testcase_24 AC 172 ms
83,672 KB
testcase_25 AC 172 ms
83,480 KB
testcase_26 AC 170 ms
83,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from typing import List


def yuki1060(grid: List[List[int]]) -> int:
    ROW, COL = len(grid), len(grid[0])
    colSum = [0] * COL
    for i in range(ROW):
        for j in range(COL):
            colSum[j] += grid[i][j]
    rowPrice = [0] * ROW
    for i in range(ROW):
        for j in range(COL):
            rowPrice[i] += grid[i][j] * colSum[j]
    rowPrice.sort(reverse=True)
    res1 = sum(rowPrice[::2])
    res2 = sum(rowPrice[1::2])
    return res1 - res2


if __name__ == "__main__":
    n, m = map(int, input().split())
    grid = [list(map(int, input().split())) for _ in range(n)]
    print(yuki1060(grid))
0