HDU 4647 Another Graph Game(贪心)
思路题。看的题解。
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
#define LL __int64
LL p[];
int main()
{
int i,n,m,sv,ev,w;
while(scanf("%d%d",&n,&m)!=EOF)
{
memset(p,,sizeof(p));
for(i = ;i <= n;i ++)
{
scanf("%I64d",&p[i]);
p[i] = p[i]*;
}
for(i = ;i < m;i ++)
{
scanf("%d%d%d",&sv,&ev,&w);
p[sv] += w;
p[ev] += w;
}
sort(p+,p+n+);
LL ans = ;
for(i = ;i <= n;i ++)
{
if(i%)
ans -= p[i];
else
ans += p[i];
}
printf("%I64d\n",ans/);
}
return ;
}
HDU 4647 Another Graph Game(贪心)的更多相关文章
- HDU 4647 Another Graph Game 思路+贪心
官方题解: 若没有边权,则对点权从大到小排序即可.. 考虑边,将边权拆成两半加到它所关联的两个点的点权中即可. ..因为当两个人分别选择不同的点时,这一权值将互相抵消. #include <cs ...
- hdu 4647 Another Graph Game
题意: 有N个点,M条边. 点有权值, 边有权值. Alice, Bob 分别选点. 如果一条边的两个顶点被同一个人选了, 那么能获得该权值.问 Alice - Bob? 链接:http://acm. ...
- hdu 4647 - Another Graph Game(思路题)
摘自题解: 若没有边权,则对点权从大到小排序即可.. 考虑边,将边权拆成两半加到它所关联的两个点的点权中即可. ..因为当两个人分别选择不同的点时,这一权值将互相抵消. 代码如下: #include ...
- HDU 4647 Another Graph Game 想法类
解题思路:若没有边权,则对点权从大到小排序即可.. 考虑边,将边权拆成两半加到它所关联的两个点的点权中即可. ..因为当两个人分别选择不同的点时,这一权值将互相抵消. 以上摘自杭电的解题报告. 至于为 ...
- hdu 4647 Another Graph Game,想到了就是水题了。。
题目是给一个无向图,其中每个节点都有点权,边也有边权,然后就有2个小朋友开始做游戏了ALICE &BOB 游戏规定ALICE 先行动然后是BOB,然后依次轮流行动,行动时可以任意选取一个节点并 ...
- HDU 6321 Dynamic Graph Matching
HDU 6321 Dynamic Graph Matching (状压DP) Problem C. Dynamic Graph Matching Time Limit: 8000/4000 MS (J ...
- hdu 4825 Xor Sum(trie+贪心)
hdu 4825 Xor Sum(trie+贪心) 刚刚补了前天的CF的D题再做这题感觉轻松了许多.简直一个模子啊...跑树上异或x最大值.贪心地让某位的值与x对应位的值不同即可. #include ...
- HDU-4647 Another Graph Game 贪心,博弈
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4647 注意这题两人的决策是想要使得自己的分数与对方的差值最大.. 注意到数据范围,显然是贪心之类的,如 ...
- UVA 10720 Graph Construction 贪心+优先队列
题目链接: 题目 Graph Construction Time limit: 3.000 seconds 问题描述 Graph is a collection of edges E and vert ...
随机推荐
- Missing Ranges & Summary Ranges
Missing Ranges Given a sorted integer array where the range of elements are [lower, upper] inclusive ...
- mysql 源码下载列表
2013年11月16日 14:57:04 http://download.softagency.net/MySQL/Downloads/MySQL-5.5/ http://code.google.co ...
- 浅谈mysql集群
一.什么是MySQL集群 MySQL集群是一个无共享的(shared-nothing).分布式节点架构的存储方案,其目的是提供容错性和高性能. 数据更新使用读已提交隔离级别(read-committe ...
- Python——内置类型
Python定义了丰富的数据类型,包括: 数值型:int, float, complex 序列:(iterable) str, unicode, tuple, list, bytearray, buf ...
- Java for LeetCode 023 Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 解 ...
- Fedora install chrome
1)下载chrome:chrome download,选择rpm版,下载地址:https://dl.google.com/linux/direct/google-chrome-stable_curre ...
- RocketMQ最佳实践
1.RocketMQ中的专业术语 Topic topic表示消息的第一级类型,比如一个电商系统的消息可以分为:交易消息.物流消息...... 一条消息必须有一个Topic. Tag Tag表示消息的第 ...
- Cocos2dx中零散知识点
cocos2dx中有三种定时器:schedule,scheduleUpdate,scheduleOnce.功能分别是 每隔几秒调用自定义函数.调用系统默认的update()函数.只调用一次自定义函数 ...
- caffe 无GPU 环境搭建
root@k-Lenovo:/home/k# sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-d ...
- ytu 1041: 迭代法求平方根(水题)
1041: 迭代法求平方根 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 227 Solved: 146[Submit][Status][Web Bo ...