結果
| 問題 |
No.1912 Get together 2
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-16 15:59:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,137 bytes |
| コンパイル時間 | 540 ms |
| コンパイル使用メモリ | 81,820 KB |
| 実行使用メモリ | 99,484 KB |
| 最終ジャッジ日時 | 2025-04-16 16:03:43 |
| 合計ジャッジ時間 | 12,899 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)]
# Precompute potential sums for each box
potential = [0] * m
for j in range(m):
for i in range(n):
if s_list[i][j] == 'o':
potential[j] += v[i]
# Pair each value with its corresponding S string and sort in descending order of value
slimes = sorted(zip(v, s_list), key=lambda x: -x[0])
box_sums = [0] * m
for value, s in slimes:
allowed = []
for j in range(m):
if s[j] == 'o':
allowed.append(j)
# Find the maximum current sum among allowed boxes
max_current = max(box_sums[j] for j in allowed)
candidates = [j for j in allowed if box_sums[j] == max_current]
# Among candidates, select the one with the highest potential
max_pot = max(potential[j] for j in candidates)
final_candidates = [j for j in candidates if potential[j] == max_pot]
# Choose the smallest index if there are still ties
selected = min(final_candidates)
box_sums[selected] += value
# Calculate the sum of squares
total = sum(x * x for x in box_sums)
print(total)
lam6er