评测结果链接:https://www.luogu.com.cn/record/42525660
不仅MLE,而且耗时也很奇怪,都在70ms以上,正常的话小点应该很快就跑过去了啊
#include<bits/stdc++.h>
using namespace std;
int head[200005],nextt[500005],to[500005],tot;
int cost[200005];
int ans,n,m;
void dfs(int mark,int minn)
{
ans=max(ans,cost[mark]-minn);
minn=min(minn,cost[mark]);
if(mark==n)return;
for(int j=head[mark];j;j=nextt[j])
{
int y=to[j];
dfs(y,minn);
}
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)scanf("%d",&cost[i]);
for(int i=1;i<=m;i++)
{
int g1,g2;scanf("%d%d",&g1,&g2);
to[++tot]=g2;nextt[tot]=head[g1];head[g1]=tot;
// to[++tot]=g1;nextt[tot]=head[g2];head[g2]=tot;
}
dfs(1,2100000000);
printf("%d",ans);
}