hduAnother Graph Game
http://acm.hdu.edu.cn/showproblem.php?pid=4647
很扯的一题 将每条边的一半权值分给它所连的两个结点
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<stdlib.h> 5 #include<algorithm> 6 using namespace std; 7 double a[100010]; 8 int main() 9 { 10 int i,j,n,m,u,v; 11 while(cin>>n>>m) 12 { 13 for(i = 1; i <= n ;i++) 14 cin>>a[i]; 15 double s; 16 for(i = 1; i <= m ; i++) 17 { 18 scanf("%d%d%lf",&u,&v,&s); 19 a[u]+=s/2; 20 a[v]+=s/2; 21 } 22 sort(a+1,a+n+1); 23 double s1=0,s2=0; 24 for(i = 1; i <= n ;i++) 25 { 26 if(i%2!=0) 27 s1+=a[i]; 28 else 29 s2+=a[i]; 30 } 31 long long k = max(s1,s2)-min(s1,s2); 32 cout<<k<<endl; 33 } 34 return 0; 35 }