結果
| 問題 |
No.1912 Get together 2
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-26 15:45:10 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,172 bytes |
| コンパイル時間 | 231 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 102,380 KB |
| 最終ジャッジ日時 | 2025-03-26 15:45:31 |
| 合計ジャッジ時間 | 18,286 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 30 |
ソースコード
n, m = map(int, input().split())
v = list(map(int, input().split()))
s_list = [input().strip() for _ in range(n)]
# Create list of slimes with their values and compatibility strings, sorted by value descending
slimes = sorted(zip(v, s_list), key=lambda x: (-x[0], x[1]))
# Precompute sumVj for each box j (1-based)
sumVj = [0] * (m + 1) # sumVj[1] to sumVj[m]
for j in range(1, m + 1):
total = 0
for i in range(n):
if s_list[i][j-1] == 'o':
total += v[i]
sumVj[j] = total
# Initialize current sum for each box (1-based)
current_sum = [0] * (m + 1)
for value, s in slimes:
allowed = []
for j in range(1, m + 1):
if s[j-1] == 'o':
allowed.append(j)
# Find the maximum current sum among allowed boxes
max_cs = max(current_sum[j] for j in allowed)
# Collect all boxes that have this maximum current sum
candidates = [j for j in allowed if current_sum[j] == max_cs]
# Choose the candidate with the highest sumVj
selected = max(candidates, key=lambda x: sumVj[x])
current_sum[selected] += value
# Calculate the total sum of squares
total = sum(s * s for s in current_sum)
print(total)
lam6er