結果
| 問題 |
No.2915 辺更新価値最大化
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2024-10-31 02:14:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 893 bytes |
| コンパイル時間 | 507 ms |
| コンパイル使用メモリ | 82,416 KB |
| 実行使用メモリ | 100,600 KB |
| 最終ジャッジ日時 | 2024-10-31 02:14:17 |
| 合計ジャッジ時間 | 11,863 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 TLE * 1 |
ソースコード
import sys
input = sys.stdin.readline
from heapq import heappop,heappush
N,M,C=map(int,input().split())
EDGE=[list(map(int,input().split())) for i in range(M)]
for i in range(M):
EDGE[i][0]-=1
EDGE[i][1]-=1
Q=list(map(int,input().split()))
for i in range(C):
Q[i]-=1
USE=[1]*M
for q in Q:
USE[q]^=1
DP=[-1<<63]*N
DP[0]=0
Q=[(0,0)]
E=[[] for i in range(N)]
for i in range(M):
if USE[i]==0:
continue
x,y,dis=EDGE[i]
E[x].append((y,dis))
#print(E)
while Q:
now,ind=heappop(Q)
if DP[ind]!=-now:
continue
now=-now
for to,w in E[ind]:
if DP[to]<now+w:
DP[to]=now+w
heappush(Q,(-DP[to],to))
if DP[-1]<-1000000000:
print("NaN")
else:
print(DP[-1])
titia