Eternality @ 2022-10-19 21:26:50
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6;
int n,m,b;
int to[N],nxt[N],h[N],w[N],tot;
int dis[N],v[N],ch[N];
void add(int x,int y,int z)
{
to[++tot]=y;
nxt[tot]=h[x];
h[x]=tot;
w[x]=z;
}
void SPFA(int maxx)
{
memset(dis,0x3f,sizeof dis);
memset(v,0,sizeof v);
queue<int> q;
if(ch[1]>maxx)return;
q.push(1);
dis[1]=0;
v[1]=1;
while(q.size())
{
int x=q.front();
q.pop();
v[x]=0;
for(int i=h[x];i;i=nxt[i])
{
int y=to[i];
int z=w[i];
if(ch[y]>maxx)continue;
if(dis[y]>dis[x]+z)
{
dis[y]=dis[x]+z;
if(!v[y])q.push(y),v[y]=1;
}
}
}
}
bool check(int x)
{
SPFA(x);
if(dis[n]>b)return false;
return true;
}
signed main()
{
scanf("%lld%lld%lld",&n,&m,&b);
for(int i=1;i<=n;i++)
{
scanf("%lld",&ch[i]);
}
for(int i=1;i<=m;i++)
{
int x,y,z;
scanf("%lld%lld%lld",&x,&y,&z);
add(x,y,z);
add(y,x,z);
}
int l=0,r=1e9,ans=-311;
while(l<=r)
{
int mid=l+r>>1;
if(check(mid))
{
ans=mid;
r=mid-1;
}else l=mid+1;
}
if(ans==-311)cout<<"AFK";
else cout<<ans;
return 0;
}
by Eternality @ 2022-10-19 21:32:17
@Ice_function 这板子没问题
by char_phi @ 2022-10-19 21:32:26
@Ice_function 显然不是这个的问题
by Eternality @ 2022-10-19 21:39:33
@char_phi 就走了?不考虑帮帮我么。。。
by WeiFanbo @ 2022-10-19 21:40:36
哥们你建边错了
by char_phi @ 2022-10-19 21:40:37
@Eternality 我在看啊
by char_phi @ 2022-10-19 21:41:09
哦woc确实建边错了
by char_phi @ 2022-10-19 21:41:47
void add(int x,int y,int z)
{
to[++tot]=y;
nxt[tot]=h[x];
h[x]=tot;
w[tot]=z;// 给这里的w[x]=z改成w[tot]=z
}
by WeiFanbo @ 2022-10-19 21:42:11
改成w[h[x]]=z就过了
by WeiFanbo @ 2022-10-19 21:43:40
能过那么多点也挺神奇
by Alone0213 @ 2022-10-19 21:45:03
确实,神奇数据