結果
問題 |
No.1912 Get together 2
|
ユーザー |
![]() |
提出日時 | 2025-06-12 20:50:13 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,016 bytes |
コンパイル時間 | 213 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 182,224 KB |
最終ジャッジ日時 | 2025-06-12 20:54:58 |
合計ジャッジ時間 | 24,685 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 3 WA * 29 TLE * 1 |
ソースコード
def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx += 1 M = int(input[idx]) idx +=1 V = list(map(int, input[idx:idx+N])) idx += N S = [] for _ in range(N): S.append(input[idx]) idx +=1 boxes = [] for j in range(M): allowed = [] for i in range(N): if S[i][j] == 'o': allowed.append((V[i], i)) allowed.sort(reverse=True, key=lambda x: x[0]) total = sum(v for v, i in allowed) boxes.append((-total, allowed, j)) boxes.sort() boxes = [ (allowed, j) for (total, allowed, j) in boxes ] assigned = [False] * N sum_squares = 0 for allowed, j in boxes: current_sum = 0 for v, i in allowed: if not assigned[i]: current_sum += v assigned[i] = True sum_squares += current_sum ** 2 print(sum_squares) if __name__ == "__main__": main()