hdu 4647 - Another Graph Game(思路题)
来源:互联网 发布:java代码基础 编辑:程序博客网 时间:2024/06/08 02:32
摘自题解:
若没有边权,则对点权从大到小排序即可。。
考虑边,将边权拆成两半加到它所关联的两个点的点权中即可。
。。因为当两个人分别选择不同的点时,这一权值将互相抵消。
代码如下:
#include <cstdio>#include <cstring>#include <algorithm>#define LL long long#define INF 0x7fffffff#define M 100010using namespace std;int comp(const double a, const double b) { return a<b; }double node[M];int main (){ int n, m; while(~scanf("%d%d",&n, &m)) { for(int i = 1; i <= n; ++i) scanf("%lf",&node[i]); int u, v, w; for(int i = 1; i <= m; ++i) { scanf("%d%d%d",&u, &v, &w); node[u] += w/2.0; node[v] += w/2.0; } sort(node+1,node+1+n,comp); double ans = 0; for(int i = n; i >=2; i-=2) ans+=node[i]-node[i-1]; printf("%.0lf\n",ans); } return 0;}
- hdu 4647 - Another Graph Game(思路题)
- hdu 4647 Another Graph Game
- HDU 4647 Another Graph Game
- hdu 4647 Another Graph Game
- hdu 4647Another Graph Game
- hdu 4647——Another Graph Game
- HDU-4647 Another Graph Game 贪心
- hdu 4647 Another Graph Game (贪心)
- hdu 4647 Another Graph Game(高效)
- hdu 4647 Another Graph Game 多校第五场
- 2013 多校第五场 hdu 4647 Another Graph Game
- hdu - 4647 - Another Graph Game(分割权)
- hdu 4647 Another Graph Game 贪心 解题报告
- hdu 4647 Another Graph Game,想到了就是水题了。。
- Another Graph Game
- HDU4647:Another Graph Game(贪心)
- HDU4647 Another Graph Game 签到
- Another Graph Game(hdu4647,拆边+贪心)
- POJ 3358 Period of an Infinite Binary Expansion(欧拉定理)
- hdu 4647 Another Graph Game
- eclipse导出jar(java打包导出jar)
- 试试功能-。-
- Oracle 常用命令
- hdu 4647 - Another Graph Game(思路题)
- linux内核分析笔记----虚拟文件系统(上)
- UVA 11636 - Hello World!
- uva 307 Sticks(DFS+ 剪枝)
- 自定义标签
- c++学习之继承
- 程序员的十楼层。看看自己在第几层。很有意思的文章!绝对给力!
- C++ 文件的复制、删除、重命名
- 老师讲的消息机制