hduAnother Graph Game
http://acm.hdu.edu.cn/showproblem.php?pid=4647
很扯的一题 将每条边的一半权值分给它所连的两个结点
#include <iostream>
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
using namespace std;
double a[];
int main()
{
int i,j,n,m,u,v;
while(cin>>n>>m)
{
for(i = ; i <= n ;i++)
cin>>a[i];
double s;
for(i = ; i <= m ; i++)
{
scanf("%d%d%lf",&u,&v,&s);
a[u]+=s/;
a[v]+=s/;
}
sort(a+,a+n+);
double s1=,s2=;
for(i = ; i <= n ;i++)
{
if(i%!=)
s1+=a[i];
else
s2+=a[i];
}
long long k = max(s1,s2)-min(s1,s2);
cout<<k<<endl;
}
return ;
}
hduAnother 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 ...
随机推荐
- 纯代码添加约束条件(Auto Layout)
Auto Layout 是一种基于约束的.描述性的布局系统.也就是使用约束条件来描述布局,View的Frame会根据这些描述来进行计算. 在iOS6.0以后加入了一个新类: NSLayoutConst ...
- mysql空间数据相关操作
建表语句: CREATE TABLE ts.points ( name ) NOT NULL, location POINT NOT NULL, description ) ); 添加记录如下: IN ...
- Java对象的序列化与反序列化:默认格式及JSON格式(使用jackson)
我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3558663.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验 ...
- [转载]浅析STL allocator
本文转载自水目沾博客:http://www.cnblogs.com/zhuwbox/p/3699977.html 向大师致敬 一般而言,我们习惯的 C++ 内存配置操作和释放操作是这样的: 1 c ...
- 九度OJ 1385 重建二叉树
题目地址:http://ac.jobdu.com/problem.php?pid=1385 题目描述: 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树.假设输入的前序遍历和中序遍历的结果中都 ...
- Linux 系统结构详解
Linux 系统结构详解 Linux系统一般有4个主要部分: 内核.shell.文件系统和应用程序.内核.shell和文件系统一起形成了基本的操作系统结构,它们使得用户可以运行程序.管理文件并使用系统 ...
- CenOS6.4 系统升级内核
获取要升级的内核版本的包 #wget -c https://www.kernel.org/pub/linux/kernel/v3.x/内核版本 若得到的内核的压缩格式为tar.xz,则需要两步解压 # ...
- JavaScript 继承的几种模式
/** * Created by 2016 on 2016/6/5. */ //1.原型链继承 //把子类的原型,定义为超类的实例 通过原型来访问超类的方法和属性 function Person(){ ...
- Oracle OEM重建
参考博客:http://blog.csdn.net/tianlesoftware/article/details/4702978 测试环境: C:\Users\Administrator>sql ...
- UML_时序图画法
UML建模之时序图(Sequence Diagram) 一.时序图简介(Brief introduction) 二.时序图元素(Sequence Diagram Elements) 角色(Actor) ...