結果
| 問題 |
No.3201 Corporate Synergy
|
| コンテスト | |
| ユーザー |
回転
|
| 提出日時 | 2025-07-11 22:33:02 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 731 bytes |
| コンパイル時間 | 319 ms |
| コンパイル使用メモリ | 82,236 KB |
| 実行使用メモリ | 67,700 KB |
| 最終ジャッジ日時 | 2025-07-11 22:33:08 |
| 合計ジャッジ時間 | 2,738 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 2 |
| other | RE * 20 |
ソースコード
from pulp import *
N = int(input())
P = list(map(int,input().split()))
M = int(input())
edge = []
for _ in range(M):
u,v = list(map(int,input().split()))
u -= 1;v -= 1
edge.append((u,v))
more = []
K = int(input())
for _ in range(K):
a,b,s = list(map(int,input().split()))
a -= 1;b -= 1
more.append((a,b,s))
p = LpProblem(sense=LpMaximize)
x = [LpVariable(f"x_{i}",cat=LpBinary) for i in range(N)]
p += lpSum(P[i] * x[i] for i in range(N)) + lpSum(s for a,b,s in more if x[a] == x[b] == 1)
for u,v in edge:
p += x[u] >= x[v]
solver = PULP_CBC_CMD(msg=False)
p.solve(solver)
print(round(sum([P[i] * x[i].value() for i in range(N)]) + sum([s for a,b,s in more if x[a].value() == x[b].value() == 1])))
回転