結果

問題 No.1060 素敵な宝箱
ユーザー wolgnikwolgnik
提出日時 2020-05-22 23:34:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 438 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 76,544 KB
最終ジャッジ日時 2024-04-15 19:04:59
合計ジャッジ時間 2,819 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
51,968 KB
testcase_01 AC 44 ms
51,840 KB
testcase_02 AC 43 ms
51,968 KB
testcase_03 AC 43 ms
51,968 KB
testcase_04 AC 43 ms
52,096 KB
testcase_05 AC 43 ms
51,840 KB
testcase_06 AC 43 ms
51,840 KB
testcase_07 AC 43 ms
52,096 KB
testcase_08 AC 56 ms
61,440 KB
testcase_09 AC 58 ms
61,312 KB
testcase_10 AC 56 ms
60,928 KB
testcase_11 AC 57 ms
61,056 KB
testcase_12 AC 67 ms
66,688 KB
testcase_13 AC 68 ms
68,992 KB
testcase_14 AC 72 ms
70,016 KB
testcase_15 AC 80 ms
76,416 KB
testcase_16 AC 74 ms
71,552 KB
testcase_17 AC 65 ms
65,664 KB
testcase_18 AC 72 ms
68,992 KB
testcase_19 AC 70 ms
67,712 KB
testcase_20 AC 76 ms
73,088 KB
testcase_21 AC 75 ms
72,704 KB
testcase_22 AC 75 ms
72,832 KB
testcase_23 AC 71 ms
67,840 KB
testcase_24 AC 86 ms
76,544 KB
testcase_25 AC 85 ms
76,416 KB
testcase_26 AC 86 ms
76,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
table = [0] * M
for i in range(N):
  for j in range(M): table[j] += a[i][j]
a.sort(key = lambda x: -sum([x[i] * table[i] for i in range(M)]))
res = 0
for i in range(N):
  x = a[i]
  if i % 2 == 0: res += sum([x[i] * table[i] for i in range(M)])
  else: res -= sum([x[i] * table[i] for i in range(M)])
print(res)
0