結果
| 問題 | No.1912 Get together 2 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-09-20 21:44:26 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 946 bytes | 
| コンパイル時間 | 193 ms | 
| コンパイル使用メモリ | 82,232 KB | 
| 実行使用メモリ | 164,880 KB | 
| 最終ジャッジ日時 | 2024-06-24 01:21:05 | 
| 合計ジャッジ時間 | 7,248 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 3 WA * 30 | 
ソースコード
import sys
input = lambda : sys.stdin.readline().rstrip()
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))
n,m = list(map(int, input().split()))
vs = list(map(int, input().split()))
ns = [[] for _ in range(n)]
ns2 = [[] for _ in range(m)]
vals = [0]*m
for i in range(n):
    s = input()
    for j in range(m):
        if s[j]=="o":
            ns[i].append(j)
            ns2[j].append(i)
            vals[j] += vs[i]
ans = 0
done = [0]*n
for _ in range(m):
    best = (-1, None)
    for j in range(m):
        if vals[j]<=-1:
            continue
        if best[0]<vals[j]:
            best = (vals[j], j)
    v, j = best
#     print(vals, v, j)
    assert j!=-1
    vals[j] = -1
    ans += v*v
    for i in ns2[j]:
        if done[i]:
            continue
        done[i] = 1
        vv = vs[i]
        for jj in ns[i]:
            vals[jj] -= vv
print(ans)
            
            
            
        