結果

問題 No.1060 素敵な宝箱
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-03-23 22:47:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2024-04-20 06:49:24
合計ジャッジ時間 3,009 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,352 KB
testcase_01 AC 38 ms
52,224 KB
testcase_02 AC 39 ms
52,224 KB
testcase_03 AC 39 ms
52,352 KB
testcase_04 AC 39 ms
52,224 KB
testcase_05 AC 39 ms
52,096 KB
testcase_06 AC 38 ms
52,096 KB
testcase_07 AC 38 ms
51,968 KB
testcase_08 AC 48 ms
61,184 KB
testcase_09 AC 57 ms
61,568 KB
testcase_10 AC 48 ms
60,928 KB
testcase_11 AC 48 ms
61,312 KB
testcase_12 AC 57 ms
66,816 KB
testcase_13 AC 60 ms
68,992 KB
testcase_14 AC 59 ms
69,888 KB
testcase_15 AC 67 ms
76,416 KB
testcase_16 AC 61 ms
70,784 KB
testcase_17 AC 54 ms
65,536 KB
testcase_18 AC 59 ms
68,608 KB
testcase_19 AC 57 ms
68,096 KB
testcase_20 AC 60 ms
72,576 KB
testcase_21 AC 60 ms
72,064 KB
testcase_22 AC 61 ms
72,320 KB
testcase_23 AC 57 ms
67,584 KB
testcase_24 AC 68 ms
76,672 KB
testcase_25 AC 68 ms
76,672 KB
testcase_26 AC 68 ms
76,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]
Stonesum = [0]*m
for i in range(n):
    for j in range(m):
        Stonesum[j] += A[i][j]

W = [[0,i] for i in range(n)]

for i in range(n):
    count = 0
    for j in range(m):
        count += A[i][j]*Stonesum[j]
    W[i][0] = count

I = [0]*m
E = [0]*m
W.sort(reverse=True)
for i in range(n):
    ind = W[i][1]
    if i%2:
        for j in range(m):
            E[j] += A[ind][j]
    else:
        for j in range(m):
            I[j] += A[ind][j]

calI = sum([i**2 for i in I])
calE = sum([e**2 for e in E])
print(calI-calE)

0