$2016$长城信息杯中国大学生程序设计竞赛中南邀请赛$J$题

贪心。

优先删除$power$大的点。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-; const int maxn=;
int p[maxn],n;
vector<int>g[maxn];
struct X { int h,p; }s[maxn];
bool f[maxn]; bool cmp(X a,X b) {return a.p>b.p;}
int main()
{
while(~scanf("%d",&n))
{
for(int i=;i<=n;i++)
{
scanf("%d",&s[i].p), s[i].h=i;
p[i]=s[i].p;
}
sort(s+,s++n,cmp); memset(f,,sizeof f);
for(int i=;i<=n;i++) g[i].clear();
for(int i=;i<=n-;i++)
{
int a,b; scanf("%d%d",&a,&b);
g[a].push_back(b); g[b].push_back(a);
} LL ans=;
for(int i=;i<=n;i++)
{
for(int j=;j<g[s[i].h].size();j++)
{
int to=g[s[i].h][j];
if(f[to]) continue;
ans=ans+(LL)p[to];
}
f[s[i].h]=;
}
cout<<ans<<endl;
}
return ;
}

XTU 1252 Defense Tower的更多相关文章

  1. XTUOJ 1252 Defense Tower 贪心

    题目链接:http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1252 思路:考虑每条边对玩家的伤害 假设连接的节点是u,v,破坏 ...

  2. [ZOJ 3623] Battle Ships

    Battle Ships Time Limit: 2 Seconds      Memory Limit: 65536 KB Battle Ships is a new game which is s ...

  3. ZOJ3623:Battle Ships(全然背包)

    Battle Ships is a new game which is similar to Star Craft. In this game, the enemy builds a defense ...

  4. ZOJ 3623 Battle Ships DP

    B - Battle Ships Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Subm ...

  5. Battle Ships(复习泛化物品**)

    传送门Battle Ships Time Limit: 2 Seconds      Memory Limit: 65536 KB Battle Ships is a new game which i ...

  6. zoj3623 Battle Ships

    Battle Ships is a new game which is similar to Star Craft. In this game, the enemy builds a defense ...

  7. dp --- hdu 4939 : Stupid Tower Defense

    Stupid Tower Defense Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/ ...

  8. hdu4939 Stupid Tower Defense (DP)

    2014多校7 第二水的题 4939 Stupid Tower Defense Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 131 ...

  9. Stupid Tower Defense

    Problem Description FSF is addicted to a stupid tower defense game. The goal of tower defense games ...

随机推荐

  1. 关于C#时间格式化中的“f”

    示例: DateTime.Now.ToString("yyyyMMddHHmmssfff") 上面的示例就是将日期格式化到毫秒级.那么问题来了,格式化到微秒级.纳秒级怎么整?f又是 ...

  2. 测试Data ORM的性能

    闲着无聊,测试了一下公司ORM的性能,和其它的ORM相比,该有的都有了,不该有的也勉强塞了进去,总体考虑是并发与扩展性问题,譬如读写分离,消息总线服务整合,缓存内置. 测试机是I7,16G内存,这里只 ...

  3. springMVC3学习(一)--框架搭建

    由于项目需要,学习下springMVC,在此简单记录一下. 如有十万个为什么,暂且忽略,待以后研究. 本人是基于3.1.1版本开发,如遇jar包版本冲突等其他问题,概不负责. 下载地址:上传此zip资 ...

  4. 搜狗主页页面CSS学习小记

    1.边框的处理   要形成上图所示的布局效果,即,点选后,导航下面的边框不显示而其他的边框形成平滑的形状.相对于把导航的下面边框取消然后用空白覆盖掉下面搜索栏的边框比较而言,sougou有很好的方法来 ...

  5. IoC in Spring

    写两个关于Spring中使用IoC的小例子,一个是半动态创建Bean,另一个是全动态创建Bean,它们适合不同的应用场景. 一.半动态:在一个实际项目中遇到过这样的问题,项目组开发的某个系统具备在LE ...

  6. 纯Python综合图像处理小工具(1)分通道直方图

    平时工作经常需要做些图像分析,需要给图像分通道,计算各个通道的直方图分布特点,这个事儿photoshop也能做,但是用起来不方便,且需要电脑上安装有PS软件,如果用OpenCV, 更是需要在visua ...

  7. 当ArcGIS10.2遇到Teradata

                                    随着计算机技术的不断发展,GIS技术也紧跟IT技术的热潮,从三维技术.到移动技术,从大数据技术到云计算技术,只要IT有的新技术,Esri ...

  8. listView 分页加载数据

    Android应用 开发中,采用ListView组件来展示数据是很常用的功能,当一个应用要展现很多的数据时,一般情况下都不会把所有的数据一次就展示出来,而是通过分页 的形式来展示数据,个人觉得这样会有 ...

  9. 用python写爬虫

    Python提供了许多Module,通过这些Module,可以很简单的做一些工作.比如,要获得cloga这个词在百度搜索结果页中的排名结果(排名结果+URL),这就是一个很简单的爬虫需求. 首先,要通 ...

  10. avalon1.5+中组件的定义方式

    avalon在1.5之后引入新的组件定义和使用方式,其总的宗旨是为了使定义和使用组件更加简单 组件库的概念 首先,需要注意的是,引入了组件库的概念(也可以理解为namespace),之后定义的组件必须 ...