zero2005 @ 2020-08-23 19:46:11
#include<bits/stdc++.h>
using namespace std;
const int mx =2000001;
vector<int>ver[mx];
vector<int>edge[mx];
int d[mx],v[mx];
priority_queue< pair < int , int> >q;
int n,m,b,ai,bi,ci,fi,maxn=-999;
int a[mx];
void add(int x,int y,int z)
{
ver[x].push_back(y);
edge[x].push_back(z);
}
int check(int x)
{
if(a[1]>x)return 0;
for(int i = 1; i <= n; ++ i){
d[i] = 1e18;
v[i] = 0;
}
d[1]=0;
q.push(make_pair(0,1));
while(q.size())
{
int u=q.top().second;
q.pop();
if(v[u])continue;
v[u]=1;
for(int i=0;i<ver[u].size();i++)
{
long long z=edge[u][i];
int y=ver[u][i];
if(a[y]>x)continue;
if(d[u]+z<d[y])
{
d[y]=d[u]+z;
q.push(make_pair(-d[y],y));
if(y==n)
{
if(d[n]>=b)return 0;
else return 1;
}
}
}
}
}
int main()
{
cin>>n>>m>>b;
for(int i=1;i<=n;i++)
{
cin>>a[i];
if(a[i]>maxn)maxn=a[i];
}
for(int i=1;i<=m;i++)
{
cin>>ai>>bi>>ci;
add(ai,bi,ci);
add(bi,ai,ci);
}
int l=1,r=maxn;
long long ans=-1;
while(l<r)
{
int mid=(l+r)>>1;
if(check(mid))
{
r=mid;
ans=mid;
}
else l=mid+1;
}
if(ans==-1)cout<<"AFK";
cout<<l;
return 0;
}
by 火羽白日生 @ 2020-08-23 20:23:27
样例都没过您为什么会交啊
by 我就是天帝 @ 2020-08-24 17:53:28
样例都没过您为什么会交啊
by Imy_bisLy @ 2020-10-17 07:51:18
特判:最后的终点点权最大,那么最大费用一点是最后的点的点权;