<html>

Source: Internet
Author: User
Tags tidy

Another Graph GameTime 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 have its own weight Wv, and every edge e have 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 has choosen that node before. One person can get the bonus attached to a edge if he/she has choosen both node that induced by the edge before.

You can assume Alice and Bob be intelligent enough and do operations optimally, both Alice and Bob's target is maximize t Heir Score-opponent ' s.

What's the final result for Alice-bob.


Inputmuilticases. The first line has a numbers n and M. (1 <= n <=, 0<=m<=105) The next line has n numbers from W1 to Wn Which Wi is the weight of node I. (| WI|&LT;=109)

The next m lines, each of the line has three numbers u, V, W, (1≤u,v≤n,|w|<=109) The first 2 numbers is the and the nodes on the E Dge, and the last one are 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;}


Read the full text of the copyright notice: This article for Bo Master original article, without Bo Master agreed not to reprint. Report
    • Label:
    • ACM /
    • Q=hdu&t=blog "target=" _blank ">hdu /

    • This article has been included in the following column:
0Article comments
Related articles recommended
hdu 4647 another Graph Game click to open hdu 4647 ideas: Greedy 1 If there is no edge, then the point right from the big to the small sort can 2 consider the side. It is possible to split the edge into two halves plus the point weights of the two points it is associated with.

Because when two people choose a different point respectively. This weight will offset each other ...

  • cgl1079743846
  • 2013-08-07 09:40
  • 788
Hdu 4647 Another Graph Game click to open hdu 4647 ideas: Greedy 1 If there is no edge right, then the point right from the big to the small sort can 2 consider the side, the edge of the right to dismantle
  • From this drunk
  • 2013-08-07 09:40
  • 47
hdu 4647 Another Graph Game if there is no edge right, then the point right from the big to the small sort can be. Consider the edge, split the edge right into two halves and add it to the two points associated with the point of the right. Because when two people choose a different point respectively. This weight will be offset against each other. #include ...
  • Hlmfjkqaz
  • 2013-08-06 19:50
  • 291
hdu 1556 Color the ball tree-like array thinking analysis [Align=left][size=medium] [color=red] There are so many blogs on the web that just give the code. This is often confused for very many people who are just touching a tree array.

I say the main idea: every time you update a point (plus a number), the prefix of all the points in the back will be the corresponding plus this number. This is actually equivalent to the number affected by this point, each time you draw a point, in fact, it is equivalent to draw all the points behind it, and then you will not need to draw the points affected by the impact of the/color][/size][/align][code= "C + +"]# Include #define LOWBIT (i) i& (-i) using namespace std;

  • weiqingliu
  • 2015-10-30 18:
  • up
another Graph Game (hdu4647, split + greedy) 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 () {scan F ("%d", &t); int m,n; while (t--) {scanf ("%d", &m), for (int i=1; i<=m
  • w Eiqingliu
  • 2015-07-25 20:38
  • +
hdu 4647-another Graph Game (IDEA) excerpt from the solution: if there is no edge right. Then the right to the point from the big to the small sort can be. Consider the edge, the edge of the right to split into two halves to its associated two points of the right to be able to ... This weight is offset against each other when two people choose a different point respectively. Code such as the following: #i ...
  • shankeliupo
  • 2013-08-06 19:51
  • 404
[hdu][segment tree]1166. Enemy soldiers, problem Military exercises are being carried out during the period of the Descriptionc country's death to country A. So the C state spy chief Derek and his men tidy started busy again.

A country has a line of N engineering camps along the coastline, and Derek and tidy are tasked with monitoring the activities of these engineering camps. Because of some advanced means of monitoring, so the number of each engineering camp is clear, the number of each engineering camp is likely to change, may add or reduce a number of personnel, but these are only the surveillance of State C. The CIA wants to study what tactics the enemy is practicing, so tidy to report to Derek at any time.

  • sunnyyoona< /li>
  • 2015-03-24 15:51
  • 28
hdu-4647-another Graph Game (cut right) test instructions: N points m edge. Each point has the right value, and each edge also has the right value, the range of weights is |w| Topic link:http://acm.hdu.edu.cn/showproblem.php?pid=4647-->> for edge right, put this ...
  • scnu_jiechao
  • 2013-08-06 21:36
  • 910
HDU 5510 Bazinga Thinking specific explanation kmp + thinking [Size=large] to a code. In the previous 22 comparison, assuming that the previous string is a string of the latter, then he is not required, assuming that the I-string is a substring of i+1. Let's say it's in the back loop. Suppose that the i+1 string is a substring of a subsequent string. There is no need for that I string, assuming that i+1 is not a substring of the back string. Ends the loop directly. Find end. Results [/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 + attention
Original
the
Fans
A
Like
0
    • Getting started with MySQL indexing
    • python handles Excel data
    • Graph Theory Summary template
    • Segment Tree Template
many other articles Online Courses

Utm_source=blog7 "target=" _blank ">

"Live" machine learning & Data Mining 7 weeks training--Wei Chi
"Package" System integration projects management project Manager smooth clearance--Xu Bong
  • folder
  • like to cancel like
  • Collection
  • share Weibo QQ
Collection Assistant Bad news report

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.