有趣的博弈题。

关键在于把比边权的平分到两边的点权上面,然后点权排序,每次从大的开始拿就可以了。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 100100
using namespace std; double a[maxn];
int n,m,u,v;
double w,s1,s0; int main()
{
while (scanf("%d%d",&n,&m)!=EOF)
{
for (int i=; i<=n; i++) scanf("%lf",&a[i]);
while (m--)
{
scanf("%d%d%lf",&u,&v,&w);
w/=;
a[u]+=w,a[v]+=w;
}
sort(a+,a++n);
s1=s0=; m=;
for (int i=n; i>; i--)
{
if (m&) s0+=a[i];
else s1+=a[i];
m++;
}
printf("%.0f\n",s0-s1);
}
return ;
}

HDU4647_Another Graph Game的更多相关文章

  1. [开发笔记] Graph Databases on developing

    TimeWall is a graph databases github It be used to apply mathematic model and social network with gr ...

  2. Introduction to graph theory 图论/脑网络基础

    Source: Connected Brain Figure above: Bullmore E, Sporns O. Complex brain networks: graph theoretica ...

  3. POJ 2125 Destroying the Graph 二分图最小点权覆盖

    Destroying The Graph Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8198   Accepted: 2 ...

  4. [LeetCode] Number of Connected Components in an Undirected Graph 无向图中的连通区域的个数

    Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), ...

  5. [LeetCode] Graph Valid Tree 图验证树

    Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), ...

  6. [LeetCode] Clone Graph 无向图的复制

    Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's ...

  7. 讲座:Influence maximization on big social graph

    Influence maximization on big social graph Fanju PPT链接: social influence booming of online social ne ...

  8. zabbix利用api批量添加item,并且批量配置添加graph

    关于zabbix的API见,zabbixAPI 1item批量添加 我是根据我这边的具体情况来做的,本来想在模板里面添加item,但是看了看API不支持,只是支持在host里面添加,所以我先在一个ho ...

  9. Theano Graph Structure

    Graph Structure Graph Definition theano's symbolic mathematical computation, which is composed of: A ...

随机推荐

  1. PhpStorm2016.2版本 安装与破解

    1.PhpStorm2016简介以及下载地址 1.1.PhpStorm介绍    PhpStorm是一个轻量级且便捷的PHP IDE,其旨在提高用户效率,可深刻理解用户的编码,提供智能代码补全 快速导 ...

  2. 20155320 2016-2017-2《Java程序设计》第1周学习总结

    20155320 2016-2017-2<Java程序设计>第1周学习总结 教材学习内容总结 本周学习内容 浏览课本,并就每一章提出一个问题. 认真学习第一.第二章的内容. 1至18章每章 ...

  3. day5 页面布局

    1.主站 <div class='pg-header'> <div style='width:980px;margin:0 auto;'> 内容自动居中 </div> ...

  4. day3 直方图

    1.绘制直方图 # coding=utf-8 import cv2 import numpy as np from matplotlib import pyplot as plt img1 = cv2 ...

  5. pyhon3.0 day01 变量、输入、输出、循环

    pyhon3.0 基础01 1 python解释器 Python的解释器很多,但使用最广泛的还是CPython.如果要和Java或.Net平台交互,最好的办法不是用Jython或IronPython, ...

  6. 八月暑期福利,10本Python热门书籍免费送!

    八月第一周,网易云社区联合博文视点为大家带来Python专场送书福利,10本关于Python的书籍内容涉及Python入门.绝技.开发.数据分析.深度学习.量化投资等.以下为书籍简介,送书福利请见文末 ...

  7. 创建Springmvc项目时,特殊拦截器失效情况的原因及解决办法

    最近开发一个新项目时,搭建springmvc框架时,遇到一个拦截器失效的情况困扰了两天.现在解决,特此记录一下. 拦截器不生效的情况描述: 设置登录拦截的时候,首先登录接口肯定是不用拦截的.所以需要在 ...

  8. 【mysql优化】mysql count(*)、count(1)、count(主键字段)、count(非主键字段)哪个性能最佳

    测试结果为:count(*)和count(1)基本相等,count(非主键字段)最耗性能 -- 数据量 708254select count(*) from tmp_test1;-- avg 0.22 ...

  9. SQL基本的45题

    -- 查询Student表中的所有记录的Sname.Ssex和Class列.SELECT Sname,Ssex,Class from student -- 查询教师所有的单位即不重复的Depart列. ...

  10. 解决WCF传输的数据量过大问题

    今天写了个WCF接口,然后自测通过,和别人联调时报 远程服务器返回错误: (413) Request Entity Too Large        错误!记得以前写的时候也出现过这个错误,大致解决办 ...