SFWR @ 2019-02-03 18:29:11
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,m,S,F,ne,hp,ans;
#define f(n,m) for(int i=n;i<=m;i++)
#define w(n) while(n--)
#define MAXN 3000001
#define INF 1e9+7
long int head[MAXN],vist[MAXN],dis[MAXN],mon[MAXN],f[MAXN];
struct Edge{int to,next,dis;
}edge[MAXN];
void adde(int from,int to,int dis){
edge[++ne].next=head[from];
edge[ne].to=to;
edge[ne].dis=dis;
head[from]=ne;
}
int spfa(int top){
f(1,n){dis[i]=INF;}
queue<int>q;
vist[1]=1;
dis[1]=0;
q.push(1);
while(!q.empty()){
int x=q.front();q.pop();vist[x]=0;
for(int i=head[x];i;i=edge[i].next){
int v=edge[i].to;
if(f[v]>top)continue;
if(dis[v]>dis[x]+edge[v].dis)
{
dis[v]=dis[x]+edge[v].dis;
if(!vist[v]){
q.push(v);vist[v]=1;
}
}
}
}
if(dis[n]>hp||dis[n]==dis[0])return 0;
else return 1;
}
int main(){cin>>n>>m>>hp;
f(1,n){cin>>f[i];mon[i]=f[i];}
sort(mon+1,mon+n+1);
w(m){std::ios::sync_with_stdio(false);cin>>a>>b>>c;adde(a,b,c);adde(b,a,c);}
if(!spfa(INF-1)){cout<<"AFK";return 0;}
int l=1,r=n;
while(l<=r){
int mid=(l+r)>>1;
if(spfa(mon[mid])) {r=mid-1;ans=mon[mid];}
else l=mid+1;
}
cout<<ans;return 0;
}
by RiverFun @ 2019-02-03 19:11:56
码风毒瘤
by SFWR @ 2019-02-03 20:48:08
@Steve_braveman QAQ
by SFWR @ 2019-02-03 21:34:21
淦,最短路写错了 打扰了,回初中重修