<html>

來源:互聯網
上載者:User

標籤:order   lsp   死對頭   ssi   blog   images   解釋   incr   機器   

Another Graph Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1691    Accepted Submission(s): 630


Problem DescriptionAlice and Bob are playing a game on an undirected graph with n (n is even) nodes and m edges. Every node i has its own weight Wv, and every edge e has its own weight We.

They take turns to do the following operations. During each operation, either Alice or Bob can take one of the nodes from the graph that haven‘t been taken before. Alice goes first.

The scoring rule is: One person can get the bonus attached to a node if he/she have choosen that node before. One person can get the bonus attached to a edge if he/she have choosen both node that induced by the edge before.

You can assume Alice and Bob are intelligent enough and do operations optimally, both Alice and Bob‘s target is maximize their score - opponent‘s.

What is the final result for Alice - Bob.

 
InputMuilticases. The first line have two numbers n and m.(1 <= n <= 105, 0<=m<=105) The next line have n numbers from W1 to Wn which Wi is the weight of node i.(|Wi|<=109)

The next m lines, each line have three numbers u, v, w,(1≤u,v≤n,|w|<=109) the first 2 numbers is the two nodes on the edge, and the last one is the weight on the edge. 
 
OutputOne line the final result.

 
Sample Input
4 09 8 6 5
 
Sample Output
2
 
Source2013 Multi-University Training Contest 5


#include <iostream>#include <cstdio>#include <string>#include <algorithm>using namespace std;#define LL long long#define maxn 100000 + 10int n, m;double a[maxn];int main(){    while(~scanf("%d%d", &n, &m))    {        for(int i=1; i<=n; i++)            scanf("%lfd", &a[i]);        int u, v;        double w;        for(int i=1; i<=m; i++)        {            scanf("%d%d%lf", &u, &v, &w);            w /= 2;            a[u] += w;            a[v] += w;        }        sort(a+1, a+1+n);        double sum1 = 0, sum2 = 0;        for(int i=n; i>=1; i--)            {                if(i & 1)                    sum2 += a[i];                else                    sum1 += a[i];            }        printf("%.0lf\n", sum1 - sum2);    }    return 0;}


閱讀全文 著作權聲明:本文為博主原創文章,未經博主同意不得轉載。 舉報
  • 標籤:
  • ACM /
  • q=Hdu&t=blog" target="_blank">Hdu /

  • 本文已收錄於下面專欄:
0條評論
相關文章推薦
hdu 4647 Another Graph Game 點擊開啟hdu 4647思路: 貪心1 若沒有邊權,則對點權從大到小排序就可以2 考慮邊。將邊權拆成兩半加到它所關聯的兩個點的點權中就可以。

由於當兩個人分別選擇不同的點時。這一權值將互相抵消...

  • cgl1079743846
  • 2013-08-07 09:40
  • 788
hdu 4647 Another Graph Game 點擊開啟hdu 4647思路: 貪心1 若沒有邊權,則對點權從大到小排序就可以2 考慮邊,將邊權拆
  • 從此醉
  • 2013-08-07 09:40
  • 47
hdu 4647 Another Graph Game 若沒有邊權,則對點權從大到小排序就可以。。考慮邊,將邊權拆成兩半加到它所關聯的兩個點的點權中就可以。由於當兩個人分別選擇不同的點時。這一權值將互相抵消。#include...
  • hlmfjkqaz
  • 2013-08-06 19:50
  • 291
hdu 1556 Color the ball 樹狀數組思路分析 [align=left][size=medium][color=red]網上非常多部落格都僅僅給了代碼。這對於非常多剛接觸樹狀數組的人來說往往一頭霧水。

我說一下主要思路:你每次更新一個點的時候(加一個數),後面全部的點的首碼和都會對應的加上這個數。這事實上就相當於這個數受了這個點影響,你每次畫一個點的時候,事實上就相當於畫了它後面全部的點,然後你把那些不必要畫的點受的影響減回來即可[/color][/size][/align][code="C++"]#include #define lowbit(i) i&(-i)using namespace std;

  • weiqingliu
  • 2015-10-30 18:47
  • 95
Another Graph Game(hdu4647,拆邊+貪心) http://acm.hdu.edu.cn/showproblem.php?pid=4647Another?Graph?GameTime?Limit:?2000/1000?MS?(Java...
  • JHC23
  • 2013-08-16 21:15
  • 503
hdu 1423 Greatest Common Increasing Subsequence 題解 [code="C++"]#include #include #include #include #include using namespace std;int dp[550];int T;int a[550],b[550];int main(){ scanf("%d",&T); int m,n; while(T--) { scanf("%d",&m); for(int i=1; i<=m
  • weiqingliu
  • 2015-07-25 20:38
  • 84
hdu 4647 - Another Graph Game(思路題) 摘自題解:若沒有邊權。則對點權從大到小排序就可以。。考慮邊,將邊權拆成兩半加到它所關聯的兩個點的點權中就可以。。。由於當兩個人分別選擇不同的點時,這一權值將互相抵消。代碼例如以下:#i...
  • shankeliupo
  • 2013-08-06 19:51
  • 404
[HDU][線段樹]1166.敵兵布陣 Problem DescriptionC國的死對頭A國這段時間進行中軍事演習。所以C國間諜頭子Derek和他手下Tidy又開始忙乎了。

A國在海岸線沿直線布置了N個工兵營地,Derek和Tidy的任務就是要監視這些工兵營地的活動情況。因為採取了某種先進的監測手段,所以每一個工兵營地的人數C國都掌握的一清二楚,每一個工兵營地的人數都有可能發生變動,可能添加或降低若干人手,但這些都逃只是C國的監視。 中央情報局要研究敵人到底演習什麼戰術,所以Tidy要隨時向Derek彙報某一段

  • SunnyYoona
  • 2015-03-24 15:51
  • 28
hdu - 4647 - Another Graph Game(切割權) 題意:n個點m條邊。每一個點有權值,每條邊也有權值,權值的範圍是 |w| 題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=4647——>>對於邊權,把這...
  • SCNU_Jiechao
  • 2013-08-06 21:36
  • 910
hdu 5510 Bazinga 思路具體解釋 kmp +思維 [size=large]來一發代碼。先前後兩兩比較,假設前一個串是後一個串的字串,那他就是不是必需的,假設第i個串是i+1的子串。假設在後面迴圈比較中。假設第i+1個串是後面串的子串。那i個串就沒有比的必要了,假設第i+1不是後面串的子串。直接結束迴圈。尋找結束。得出結果[/size][code="C++"]#include int next[10005];int T;char s[505][2005];bool v[550],flag;void getnext(char str[],int len){ int k=
  • weiqingliu
  • 2015-11-01 19:32
  • 176
Dikea‘s Blog +關注
原創
270
粉絲
12
喜歡
0
  • MYSQL索引入門
  • Python處理excel資料
  • 圖論總結模板
  • 線段樹模板
很多其它文章 線上課程

utm_source=blog7" target="_blank">

【直播】機器學習&資料採礦7周實訓--韋瑋
【套餐】系統整合專案管理project師順利通關--徐朋
  • 檔案夾
  • 喜歡 取消愛好
  • 收藏
  • 分享 微博 QQ
收藏助手 不良資訊舉報

<html>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.