HDU-4647 Another Graph Game 贪心

2015-07-20 17:43:09 · 作者: · 浏览: 5

将边权拆成两半加到它所关联的两个点的点权中即可。因为当两个人分别选择不同的点时,这一权值将互相抵消。然后排序从最优开始取。

#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #include 
       
         #include 
        
          #include 
         
           #define LL long long using namespace std; const int maxn=110000; bool cmp(LL a, LL b) { return a>b; } LL n,m; LL w[maxn]; int main() { LL u,v,l; while(scanf("%I64d%I64d",&n,&m)!=EOF) { for(LL i=1;i<=n;i++) { scanf("%I64d",&w[i]); w[i]*=2ll; } for(LL i=0;i