sabery @ 2019-10-07 15:29:45
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
const int N=1e5+10;
const int M=1e6+1;
int ver[M],nex[M],hea[N],e[M];
long long dis[N];
int f[N];
int n,m,b,tot;
queue<int> q;
bool v[N],fv[N];
inline void add(int x,int y,int z)
{
ver[++tot]=y;nex[tot]=hea[x];hea[x]=tot;e[tot]=z;
}
inline bool spfa(){
memset(dis,0x7f7f,sizeof(dis));
q.push(1);v[1]=1;dis[1]=0;
while(q.size()){
int x=q.front();q.pop();v[x]=0;
for(int i=hea[x];i;i=nex[i]){
int y=ver[i];
if(fv[y])continue;
if(dis[y]>dis[x]+e[i]){
dis[y]=dis[x]+e[i];
if(!v[y])q.push(y),v[y]=1;
}
}
}
if(dis[n]<b)return 1;
else return 0;
}
inline bool check(int x){
memset(fv,0,sizeof(fv));
for(int i=1;i<=n;i++)if(f[i]>x)fv[i]=1;
if(fv[n]||fv[1])return 0;
return spfa();
}
int main()
{
int l=0,r=0;
scanf("%d%d%d",&n,&m,&b);
for(int i=1;i<=n;i++){
scanf("%d",&f[i]);r=max(r,f[i]);
}
for(int i=1;i<=m;i++){
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
add(x,y,z);add(y,x,z);
}
while(l<r){
int mid=(l+r)>>1;
if(check(mid))r=mid;
else l=mid+1;
}
if(r==0)cout<<"AFK";
else cout<<r;
}
by Guitar_Jasmine @ 2019-10-09 11:01:04
0滴血好像还能活qwq
by sabery @ 2019-10-09 14:29:05
@柳暗花明 满血的时候它死了
by Guitar_Jasmine @ 2019-10-09 15:02:34
@刘佳棋 这题面写的好像不是那么清楚, 我0滴血还活着也过了qwq
by sabery @ 2019-10-09 15:13:09
@柳暗花明 QWQ无奈