# 题目分析

## 分析过程

#include<bits/stdc++.h>
#define re register
#define ll long long
using namespace std;
{
int k=1,sum=0;
char c=getchar();
for(;c<'0' || c>'9';c=getchar()) if(c=='-') k=-1;
for(;c>='0' && c<='9';c=getchar()) sum=sum*10+c-'0';
return sum*k;
}
int n,m,b;
struct Edge{
int to,nxt,w;
};
const int N=1e4+10,M=5e4+10;
const int inf=1000000000+10;
Edge edge[M<<1];
int rk=1;
int val[N],tp[N];
int dis[N];
bool vis[N];
inline void Add(int x,int y,int w){
}
struct New{
int u,d;
bool operator<(const New& qwq) const{
return d>qwq.d;
}
};
priority_queue<New> Q;
inline bool Check(int top){
memset(dis,0x3f3f3f3f,sizeof(dis));memset(vis,0,sizeof(vis));
dis[1]=0;
Q.push((New){1,0});
while(!Q.empty()){
New fr=Q.top();Q.pop();
if(vis[fr.u]) continue;
vis[fr.u]=1;
int x=fr.u;
int y=edge[i].to,z=edge[i].w;
if(val[y]>top) continue;
if(dis[y]>dis[x]+z)
dis[y]=dis[x]+z;
Q.push((New){y,dis[y]});
}
}
if(dis[n]<=b) return 1;else return 0;
}
int main()
{
//freopen("agrm.in","r",stdin);
for(re int i=2;i<=n;++i) {
if(val[i]<js) ++rk;   //进行点权排序
}
for(re int i=1;i<=m;++i){
}
sort(tp+1,tp+1+n); // 保证单调性，开始二分
if(!Check(inf)) {
puts("AFK");
return 0;
}
int l=rk,r=n,ans;
int mid;
while(l<=r){
mid=(l+r)>>1;
bool pd=Check(tp[mid]);
if(pd) {
r=mid-1;ans=tp[mid];
}
else l=mid+1;
}
cout<<ans;
return 0;
}

posted @ 2019-08-29 09:41  IcedMoon_YYY  阅读(173)  评论(1编辑  收藏  举报