HDU4647_Another Graph Game
有趣的博弈题。
关键在于把比边权的平分到两边的点权上面,然后点权排序,每次从大的开始拿就可以了。
#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的更多相关文章
- [开发笔记] Graph Databases on developing
TimeWall is a graph databases github It be used to apply mathematic model and social network with gr ...
- Introduction to graph theory 图论/脑网络基础
Source: Connected Brain Figure above: Bullmore E, Sporns O. Complex brain networks: graph theoretica ...
- POJ 2125 Destroying the Graph 二分图最小点权覆盖
Destroying The Graph Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8198 Accepted: 2 ...
- [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), ...
- [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), ...
- [LeetCode] Clone Graph 无向图的复制
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's ...
- 讲座:Influence maximization on big social graph
Influence maximization on big social graph Fanju PPT链接: social influence booming of online social ne ...
- zabbix利用api批量添加item,并且批量配置添加graph
关于zabbix的API见,zabbixAPI 1item批量添加 我是根据我这边的具体情况来做的,本来想在模板里面添加item,但是看了看API不支持,只是支持在host里面添加,所以我先在一个ho ...
- Theano Graph Structure
Graph Structure Graph Definition theano's symbolic mathematical computation, which is composed of: A ...
随机推荐
- 20155307 2016-2017-2 《Java程序设计》第4周学习总结
20155307 2016-2017-2 <Java程序设计>第4周学习总结 教材学习内容总结 所谓继承,讲的就是出现很多很多相同的部分的话,就把这个部分变成"父类", ...
- 20155325 实验三 敏捷开发与XP实践
实验三 敏捷开发与XP实践-1 http://www.cnblogs.com/rocedu/p/4795776.html, Eclipse的内容替换成IDEA 在IDEA中使用工具(Code-> ...
- echarts 去掉上面的小图标
在option里找到toolbox,删除对应的代码即可: toolbox: { y : -30, show : true, feature : { mark : '辅助线开关', markUndo : ...
- day3 RHCE
10.配置NFS服务 在server0配置NFS服务,要求如下: 以只读的形式共享目录/public同时只能被example.com域中的系统访问. 以读写的形式共享目录/protected同时只能被 ...
- 【LG3231】[HNOI2013]消毒
题面 洛谷 题解 代码 \(100pts\) #include<iostream> #include<cstdio> #include<cstdlib> #incl ...
- 在BAE上部署Pomelo
BAE升级到3.0后顿时感觉好用了很多,俨然云主机的感觉. 底下我将分享我在BAE上部署Pomelo的过程. 首先需要拥有一个BAE的执行单元.没有的可以自行百度并部署. 接着svn得出代码到本地.此 ...
- animation和transition
相同点 指定要侦听更改的CSS属性. 设置计时(缓和)功能以改变从一个属性值到另一个属性值的速率 指定持续时间以控制动画或转换所需的时间 以编程方式收听您可以随意执行的动画和特定于转换的事件 可视化C ...
- sqli-labs学习笔记 DAY2
DAY2 sqli-labs lesson 2 手工注入 URL:http://localhost/sqli-labs-master/Less-2/ Parameter:id 注入点检测:id=2;– ...
- nagios监控安装esxi的服务器(宿主机)
首先,该博文大部分内容来自网络,少部分是自己监控过程中遇到的问题.如果有侵权,请联系告知!!! 现在互联网公司,有能力的都是自己研发监控系统,要么就是zabbix或者小米的监控,还都二次开发等等,可能 ...
- CSS中水平居中设置的几种方式
1.行内元素: 如果被设置元素为文本.图片等行内元素时,水平居中是通过给父元素设置 text-align:center 来实现的. <body> <div class="t ...