Codeforces Round #250 (Div. 2) C、The Child and Toy
注意此题,每一个部分都有一个能量值v[i],他移除第i部分所需的能量是v[f[1]]+v[f[2]]+...+v[f[k]],其中f[1],f[2],...,f[k]是与i直接相连(且还未被移除)的部分的编号。
注意题目移除的都是与第i部分直接相连的部分的能量值,
将本题目简化得,只考虑两个点1和2,1和2相连,1的能量值是10,2的能量值是20,
移除绳子时,要保持能量最小,可以移除部分2,这样移除的能量就是与2相连的部分1的能量即是10;
故每次相连两部分都移除能量值大的即可
#include <iostream>
#include <vector>
#include <algorithm> using namespace std; int main(){
int n,m,ans = ;
cin >> n >> m;
vector<int> v(n+);
for(int i = ;i <= n ; ++ i) cin >> v[i];
for(int i = ; i < m; ++ i){
int x,y;
cin >> x >> y;
ans +=min(v[x],v[y]);
}
cout<<ans<<endl;
}
Codeforces Round #250 (Div. 2) C、The Child and Toy的更多相关文章
- Codeforces Round #437 (Div. 2)[A、B、C、E]
Codeforces Round #437 (Div. 2) codeforces 867 A. Between the Offices(水) 题意:已知白天所在地(晚上可能坐飞机飞往异地),问是否从 ...
- Codeforces Round #298 (Div. 2) A、B、C题
题目链接:Codeforces Round #298 (Div. 2) A. Exam An exam for n students will take place in a long and nar ...
- Codeforces Round #250 (Div. 2)A(英语学习)
链接:http://codeforces.com/contest/437/problem/A A. The Child and Homework time limit per test 1 secon ...
- Codeforces Round #250 (Div. 1) A. The Child and Toy 水题
A. The Child and Toy Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/438/ ...
- Codeforces Round #250 (Div. 2)——The Child and Set
题目链接 题意: 给定goal和limit,求1-limit中的若干个数,每一个数最多出现一次,且这些数的lowbit()值之和等于goal,假设存在这种一些数,输出个数和每一个数:否则-1 分析: ...
- Codeforces Round #250 (Div. 1) D. The Child and Sequence (线段树)
题目链接:http://codeforces.com/problemset/problem/438/D 给你n个数,m个操作,1操作是查询l到r之间的和,2操作是将l到r之间大于等于x的数xor于x, ...
- Codeforces Round #250 (Div. 1) D. The Child and Sequence 线段树 区间取摸
D. The Child and Sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...
- Codeforces Round #250 (Div. 1) B. The Child and Zoo 并查集
B. The Child and Zoo Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/438/ ...
- Codeforces Round #482 (Div. 2) C 、 Kuro and Walking Route(dfs)979C
题目链接:http://codeforces.com/contest/979/problem/C 大致题意 给出n个点,有n-1个边将他们链接.给出x,y,当某一路径中出现x....y时,此路不通.路 ...
随机推荐
- jcaptcha组件小小改造解决Invalid ID, could not validate une
https://my.oschina.net/chainlong/blog/192014
- 重温WCF之WCF传输安全(十三)(4)基于SSL的WCF对客户端采用证书验证(转)
转载地址:http://www.cnblogs.com/lxblog/archive/2012/09/20/2695397.html 前一篇我们演示了基于SSL的WCF 对客户端进行用户名和密码方式的 ...
- 详细的JavaScript事件使用指南
事件流 事件流描述的是从页面中接收事件的顺序,IE和Netscape提出来差不多完全相反的事件流的概念,IE事件流是事件冒泡流,Netscape事件流是事件捕获流. 事件冒泡 IE的事件流叫做事 ...
- Swipe to back not working滑动后退功能消失?
如果你发现滑动后退功能突然失效了,很可能是因为你隐藏了NavigationBar 或者定制了 leftBarButtonItem(s) 这会导致 NavigationController 的 inte ...
- C#DataGridView合计处理
网上查了一些关于合计的代码 ,但发现大都都不尽人意,就自己再根据资料改了一下. #region 合计 //调用方法示例 //HeJi heji = null; //heji = new HeJi(la ...
- SVN-简要说明
SVN官方推荐在一个版本库的根目录下先建立trunk.branches.tags这三个文件夹,其中trunk是开发主干,存放日常开发的内容:branches存放各分支的内容,比如为不同客户定制的不同版 ...
- 来访统计的JS代码
<script language="JavaScript"> var caution = false function setCookie(name, value, e ...
- C# 指针操作图像 二值化处理
/// <summary> /// 二值化图像 /// </summary> /// <param name="bmp"></param& ...
- HDU 4005 The war Tarjan+dp
The war Problem Description In the war, the intelligence about the enemy is very important. Now, o ...
- ASCIIHexDecode,RunLengthDecode
public static byte[] ASCIIHexDecode(byte[] data) { MemoryStream outResult = new MemoryStream(); bool ...