我自己都不知道这为什么能能拿60分,有人看看吗?(我原本以为是0分的)
#include<stdio.h>
#include<ctype.h>
#include <stdlib.h>
#include <string.h>
//#include<bits/stdc++.h>//不耐烦了
//#include<iostream>
//using namespace std;
#define u_std(x) using std::x
#ifdef _GLIBCXX_IOSTREAM
#define endl '\n'
using std::cin;
using std::cout;
#define Fast_IO ios::sync_with_stdio(0),cin.tie(0)
#endif
namespace OI{//好长的缺省源
#define itn int //防手残
#define un unsigned
typedef long long ll;
typedef unsigned long long ull;
typedef const int CI;
//#define rt register//编译器好像比我聪明QWQ
#define _rep(i,st,n) for(int i=(st);i<(n);++i)
#define rep(i,st,n) for(int i=(st);i<=(n);++i)
#define _dwh(i,st,n) for(int i=(st);i>(n);--i)
#define dwh(i,st,n) for(int i=(st);i>=(n);--i)
#define dw(n) while(n--)
const int L=1<<15;
char buf[L],*p1,*p2;
int my_getchar() { return (p1==p2?(p2=buf+fread(p1=buf,1,L,stdin),p1==p2?EOF:*p1++):*p1++);}
#define getchar OI::my_getchar
int read()
{
int x=0;
bool f=0;
char ch=getchar();
while(!isdigit(ch)){if(ch=='-') f=!f;ch=getchar();}
while(isdigit(ch)) x=x*10+(ch&15),ch=getchar();
if(f) return -x;
return x;
}
//#define int ll
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x<y?x:y;}
int bmax(int &x,int y){return x=max(x,y);}
int bmin(int &x,int y){return x=min(x,y);}
int up0(int x){return x>0?x:0;}
template<class T,class U>
struct __is_same{static const int value=false;};
template<class T>
struct __is_same<T,T>{static const int value=true;};
#define is_same(T,U) (OI::__is_same<T,U>::value)
CI \
MAX_add=10,
MAX_N=1e4,
MAX_M=4e5,
N=MAX_N+MAX_add,
M=MAX_M+MAX_add;
};
#include<vector>
#include<queue>
#include<algorithm>
using std::vector;
using std::queue;
struct node{
int val,num;
vector<int>v;
}g[OI::N];
int \
n,m,cost=0;
int bfs(void)
{
queue<int>q;
rep(i,1,n)
{
if(!g[i].num) q.push(i);
}
while(!q.empty())
{
int t=q.front();
cost+=OI::up0(g[t].val-cost);
q.pop();
for(int j:g[t].v)
{
g[j].num--;
if(!g[j].num) q.push(j),g[j].val+=g[t].val;
}
}
return 0;
}
signed main()
{
int u,v;
scanf("%d%d",&n,&m);
rep(i,1,n) scanf("%d",&g[i].val);
rep(i,1,m) scanf("%d%d",&u,&v),g[u].v.push_back(v),g[v].num++;
bfs();
printf("%d",cost);
return 0;
}