結果
| 問題 |
No.1912 Get together 2
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 15:38:26 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 996 bytes |
| コンパイル時間 | 210 ms |
| コンパイル使用メモリ | 82,968 KB |
| 実行使用メモリ | 120,940 KB |
| 最終ジャッジ日時 | 2025-06-12 15:38:55 |
| 合計ジャッジ時間 | 5,621 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 WA * 29 |
ソースコード
def main():
import sys
input = sys.stdin.read().split()
ptr = 0
N = int(input[ptr])
ptr += 1
M = int(input[ptr])
ptr += 1
V = list(map(int, input[ptr:ptr+N]))
ptr += N
S = []
for _ in range(N):
S.append(input[ptr])
ptr += 1
# Compute sum_boxes: sum of V_i compatible with each box j
sum_boxes = [0] * M
for j in range(M):
for i in range(N):
if S[i][j] == 'o':
sum_boxes[j] += V[i]
# Sort boxes by sum in descending order, then by index
sorted_boxes = sorted([(sum_boxes[j], j) for j in range(M)], key=lambda x: (-x[0], x[1]))
# Initialize box sums
box_sum = [0] * M
for i in range(N):
v = V[i]
s_i = S[i]
for (s, j) in sorted_boxes:
if s_i[j] == 'o':
box_sum[j] += v
break
# Compute the result
result = sum(x*x for x in box_sum)
print(result)
if __name__ == "__main__":
main()
gew1fw