結果
| 問題 |
No.1060 素敵な宝箱
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:26:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 71 ms / 2,000 ms |
| コード長 | 654 bytes |
| コンパイル時間 | 240 ms |
| コンパイル使用メモリ | 82,664 KB |
| 実行使用メモリ | 77,132 KB |
| 最終ジャッジ日時 | 2025-03-31 17:27:46 |
| 合計ジャッジ時間 | 2,521 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
n, m = map(int, input().split())
chests = [list(map(int, input().split())) for _ in range(n)]
# Calculate Tj for each jewel type
T = [0] * m
for j in range(m):
for i in range(n):
T[j] += chests[i][j]
# Calculate the value of each chest
values = []
for chest in chests:
value = sum(chest[j] * T[j] for j in range(m))
values.append(value)
# Sort values in descending order
values.sort(reverse=True)
# Calculate the sum for the first player (0th, 2nd, 4th... elements)
sum_S = 0
for i in range(0, n, 2):
sum_S += values[i]
# Calculate the final answer
sum_T_sq = sum(t * t for t in T)
result = 2 * sum_S - sum_T_sq
print(result)
lam6er