之前一直想着建图。。。遍历

可是推例子都不正确

后来看数据好像看出了点规律

就抱着试一试的心态水了一下

就。。。。过了。。。。。

后来想想我的思路还是对的

先抽象当前仅仅有两个点相连

想要拆分耗费最小,肯定拆相应权值较小的

在这个基础上考虑问题就能够了

代码例如以下:

#include <cstdio>
#include <iostream>
#include <algorithm>
#define MAXN 10010
#define ll long long
using namespace std; int v[MAXN]; int main(void) {
int n, m, x, y;
ll sum;
while(cin >> n >> m) {
sum = 0;
for(int i=1; i<=n; ++i)
cin >> v[i];
for(int i=0; i<m; ++i) {
scanf("%d %d", &x, &y);
sum += min(v[x], v[y]);
}
cout << sum << endl;
}
return 0;
}

Codeforces #250 (Div. 2) C.The Child and Toy的更多相关文章

  1. 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/ ...

  2. Codeforces Round #250 Div. 2(C.The Child and Toy)

    题目例如以下: C. The Child and Toy time limit per test 1 second memory limit per test 256 megabytes input ...

  3. Codeforces #250 (Div. 2) B. The Child and Set

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u011639256/article/details/28100041 题读错了啊... 一直跪,但刚 ...

  4. 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 ...

  5. 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/ ...

  6. 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, ...

  7. Codeforces Round #250 (Div. 2)—A. The Child and Homework

         好题啊,被HACK了.曾经做题都是人数越来越多.这次比赛 PASS人数 从2000直掉 1000人  被HACK  1000多人! ! ! ! 没见过的科技啊 1 2 4 8 这组数 被黑的 ...

  8. Codeforces Round #250 (Div. 1) D. The Child and Sequence(线段树)

    D. The Child and Sequence time limit per test 4 seconds memory limit per test 256 megabytes input st ...

  9. Codeforces Round #250 (Div. 1) D. The Child and Sequence

    D. The Child and Sequence time limit per test 4 seconds memory limit per test 256 megabytes input st ...

随机推荐

  1. 项目 erlang启动时死循环

    机子里的otp是新装的 看了一下main 是在util:ensure_started一堆app的时候死讯了, 按照顺序是sasl crypto asn1 public_key ssl 发现是publi ...

  2. gVIM 简洁配置 in Windows

    原文链接:http://www.errdev.com/post/2/ 捣鼓了一段时间的VIM,神器终归是神器,果然编码效率提升了许多,当然还需要很多插件来配合.自己装插件很麻烦,还要有Vundle这个 ...

  3. linux 操作总结

    1.集群节点之间ssh无密码登陆 参考:http://www.cnblogs.com/jdksummer/articles/2521550.html 解决: 1)删除旧有记录:rm -r ~/.ssh ...

  4. ruby 安装更新

    wget http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.gz tar xfvz ruby-2.2.2.tar.gz cd ruby-2. ...

  5. mysql 管理、备份、还原及查询的图形化gui工具

    mysql-workbench sudo apt-get install mysql-workbench

  6. nova 配置文件

    控制节点 /etc/nova/nova.conf [DEFAULT]cpu_allocation_ratio=32.0service_down_time = 7200#use_local = True ...

  7. (转载)Java里快如闪电的线程间通讯

    转自(http://www.infoq.com/cn/articles/High-Performance-Java-Inter-Thread-Communications) 这个故事源自一个很简单的想 ...

  8. Problems running django-admin

    “command not found: django-admin”¶ django-admin should be on your system path if you installed Djang ...

  9. GWT工程架构分析与理解

    上一篇文章中介绍了GWT技术的一些理论性的东西,涉及到GWT得一些技术原理及实现.接下来笔者将通过创建一个GWT工程去理解分析GWT工程架构.     GWT工程架构解析 笔者使用的是Eclipse插 ...

  10. linux 5 配置xmanager

    0 关闭防火墙或者打开177端口 iptables -A INPUT -p udp --dport 177 -j ACCEPT 1.vi /etc/inittab id:5:initdefault:  ...