ΦωΦ @ 2019-05-08 18:16:37
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#define int long long
using namespace std;
int n,m,b;
const int N=50000+5;
int a[N];
bool kill[N];
bool done[N];
int dis[N];
vector < pair < int ,int > > va[N*2+500];
void chushi(int limt)
{
for(int i=1;i<=n;i++)
kill[i]=0;
for(int i=1;i<=n;i++)
done[i]=0;
for(int i=1;i<=n;i++)
dis[i]=1e8;
for(int i=2;i<=n;i++)
if(a[i]>limt)
kill[i]=1;
}
bool SPFA(int limt)
{
if(limt<a[1])
return 0;
queue<int>v;
chushi(limt);
dis[1]=0;
v.push(1);
done[1]=1;
while(v.size())
{
int front=v.front();
v.pop();
done[front]=0;
for(int i=0;i<va[front].size();i++)
{
int to=va[front][i].first;
int dist=va[front][i].second;
if(kill[to])
continue;
if(dis[to]>dis[front]+dist)
{
dis[to]=dis[front]+dist;
if(!done[to]) v.push(to);
}
}
}
if(dis[n]>b)
return 0;
else
return 1;
}
signed main()
{
cin>>n>>m>>b;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<=m;i++)
{
int x,y,z;
cin>>x>>y>>z;
if(x==y)
continue;
va[x].push_back( make_pair (z,y));
va[y].push_back( make_pair (z,x));
}
int L=0,R=1000000000;
//cout<<SPFA(1000000000);
if(!SPFA(R))
{
cout<<"AFK";
return 0;
}
while(L<=R)
{
int mid=(L+R)/2;
if(SPFA(mid))
R=mid-1;
else
L=mid+1;
}
cout<<L;
}
RE不懂
by 紪絽 @ 2019-05-08 18:17:17
前排吃瓜
by 紪絽 @ 2019-05-08 18:19:01
我不会做题
康康有没有大佬
就是来吃瓜der
by 流逝丶 @ 2019-05-08 18:27:33
山前刘明
by t162 @ 2019-05-08 18:51:27
@不败丶流逝 ???
by ΦωΦ @ 2019-05-08 20:02:15
@不败丶流逝