XTU 1252 Defense Tower
$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的更多相关文章
- XTUOJ 1252 Defense Tower 贪心
题目链接:http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1252 思路:考虑每条边对玩家的伤害 假设连接的节点是u,v,破坏 ...
- [ZOJ 3623] Battle Ships
Battle Ships Time Limit: 2 Seconds Memory Limit: 65536 KB Battle Ships is a new game which is s ...
- ZOJ3623:Battle Ships(全然背包)
Battle Ships is a new game which is similar to Star Craft. In this game, the enemy builds a defense ...
- ZOJ 3623 Battle Ships DP
B - Battle Ships Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Subm ...
- Battle Ships(复习泛化物品**)
传送门Battle Ships Time Limit: 2 Seconds Memory Limit: 65536 KB Battle Ships is a new game which i ...
- zoj3623 Battle Ships
Battle Ships is a new game which is similar to Star Craft. In this game, the enemy builds a defense ...
- dp --- hdu 4939 : Stupid Tower Defense
Stupid Tower Defense Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/ ...
- hdu4939 Stupid Tower Defense (DP)
2014多校7 第二水的题 4939 Stupid Tower Defense Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 131 ...
- Stupid Tower Defense
Problem Description FSF is addicted to a stupid tower defense game. The goal of tower defense games ...
随机推荐
- Oracle 10g数据库概述
一.Oracle 10g简介 1.Oracle 10g数据库是首个为网咯计算而设计的数据库(甲骨文公司的一款关系数据库管理系统). 2.分为以下几个版本: a.Oracle 10g数据库标准版 1 b ...
- Html Agility Pack解析HTML页
文章来源:Html Agility Pack解析HTML页 现在,在不少应用场合中都希望做到数据抓取,特别是基于网页部分的抓取.其实网页抓取的过程实际上是通过编程的方法,去抓取不同网站网页后,再进行分 ...
- [转]Even when one byte matters
Source:http://kernelbof.blogspot.jp/2009/07/even-when-one-byte-matters.html Common Vulnerabilities a ...
- GDB-Darwin-Extentions
- 第一个python
import MySQLdb import os,sys import string dto=os.getcwd()+"\\dto" dao=os.getcwd()+"\ ...
- WPF制作的小型笔记本
WPF制作的小型笔记本-仿有道云笔记 楼主所在的公司不允许下载外部资源, 不允许私自安装应用程序, 平时记录东西都是用记事本,时间久了很难找到以前记的东西. 平时在家都用有道笔记, 因此就模仿着做了一 ...
- 更有效率的使用Visual Studio2
PS色调均化滤镜的快捷实现(C#源代码). photoshop色调均化功能通常是在进行修片处理前期比较常用的功能之一,其对扩展图像的对比度,增强视觉效果有一定的作用.在很多课本或者文章中,也称这种处理 ...
- 一步步教你读懂NET中IL(附带图)
一步步教你读懂NET中IL(附带图) 接触NET也有1年左右的时间了,NET的内部实现对我产生了很大的吸引力,在msdn上找到一篇关于NET的IL代码的图解说明,写的挺不错的.个人觉得:能对这些底部的 ...
- Linux epoll总结
Linux epoll总结 Linux epoll epoll是Kernel 2.6后新加入的事件机制,在高并发条件下,远优于select.epoll最大的好处在于它不会随着监听fd数目的增长而降低 ...
- java微信平台,发源码
最近写了一个微信平台的架构,采用servlet + spring3.0 + hibernate4.1.整体架构由我负责建设,我尽可能的把业务模块分出来.趁着刚搭好的框架,留着这版.代码是大部份都由其他 ...