結果

問題 No.1060 素敵な宝箱
ユーザー 👑 rin204rin204
提出日時 2022-10-29 14:23:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 77,752 KB
最終ジャッジ日時 2023-09-20 18:21:25
合計ジャッジ時間 4,597 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,352 KB
testcase_01 AC 72 ms
71,464 KB
testcase_02 AC 72 ms
71,344 KB
testcase_03 AC 76 ms
71,252 KB
testcase_04 AC 70 ms
71,148 KB
testcase_05 AC 72 ms
71,140 KB
testcase_06 AC 73 ms
71,064 KB
testcase_07 AC 71 ms
71,196 KB
testcase_08 AC 84 ms
76,512 KB
testcase_09 AC 82 ms
76,312 KB
testcase_10 AC 83 ms
76,232 KB
testcase_11 AC 83 ms
76,140 KB
testcase_12 AC 91 ms
76,672 KB
testcase_13 AC 92 ms
76,280 KB
testcase_14 AC 92 ms
76,276 KB
testcase_15 AC 98 ms
77,636 KB
testcase_16 AC 95 ms
76,404 KB
testcase_17 AC 89 ms
76,100 KB
testcase_18 AC 93 ms
76,624 KB
testcase_19 AC 92 ms
76,304 KB
testcase_20 AC 97 ms
77,752 KB
testcase_21 AC 97 ms
77,320 KB
testcase_22 AC 98 ms
77,636 KB
testcase_23 AC 91 ms
76,276 KB
testcase_24 AC 99 ms
77,388 KB
testcase_25 AC 99 ms
77,432 KB
testcase_26 AC 98 ms
77,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
tot = [0] * m
for row in A:
    for i, a in enumerate(row):
        tot[i] += a

for row in A:
    s = 0
    for a, t in zip(row, tot):
        s += a * t
    row.append(s)

A.sort(key=lambda x:-x[-1])
X = [0] * m
Y = [0] * m
t = 0
for row in A:
    if t == 0:
        for i, a in enumerate(row[:-1]):
            X[i] += a
    else:
        for i, a in enumerate(row[:-1]):
            Y[i] += a
    t ^= 1

def f(X):
    return sum(x ** 2 for x in X)

score = f(X) - f(Y)
print(score)
0