hduAnother Graph Game

时间:2022-01-05 08:22:48

http://acm.hdu.edu.cn/showproblem.php?pid=4647

很扯的一题 将每条边的一半权值分给它所连的两个结点

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
using namespace std;
double a[];
int main()
{
int i,j,n,m,u,v;
while(cin>>n>>m)
{
for(i = ; i <= n ;i++)
cin>>a[i];
double s;
for(i = ; i <= m ; i++)
{
scanf("%d%d%lf",&u,&v,&s);
a[u]+=s/;
a[v]+=s/;
}
sort(a+,a+n+);
double s1=,s2=;
for(i = ; i <= n ;i++)
{
if(i%!=)
s1+=a[i];
else
s2+=a[i];
}
long long k = max(s1,s2)-min(s1,s2);
cout<<k<<endl;
}
return ;
}