A. The Child and Toy

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/438/problem/A

Description

On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.

The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must remove all its parts. The child can remove a single part at a time, and each remove consume an energy. Let's define an energy value of part i as vi. The child spend vf1 + vf2 + ... + vfk energy for removing part i where f1, f2, ..., fk are the parts that are directly connected to the i-th and haven't been removed.

Help the child to find out, what is the minimum total energy he should spend to remove all n parts.

Input

The first line contains two integers n and m (1 ≤ n ≤ 1000; 0 ≤ m ≤ 2000). The second line contains n integers: v1, v2, ..., vn (0 ≤ vi ≤ 105). Then followed m lines, each line contains two integers xi and yi, representing a rope from part xi to part yi (1 ≤ xi, yi ≤ nxi ≠ yi).

Consider all the parts are numbered from 1 to n.

Output

Output the minimum total energy the child should spend to remove all n parts of the toy.

Sample Input

4 3
10 20 30 40
1 4
1 2
2 3

Sample Output

40

HINT

题意

给你一个图,然后让你删除所有边,每条边删除的代价是这条边两边点权的最小值

然后问你花费多少

题解:

跑一遍就好了,和删边顺序无关,所以随便跑啦

代码

#include<iostream>
#include<stdio.h>
using namespace std; int a[];
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
long long ans = ;
for(int i=;i<=m;i++)
{
int x,y;scanf("%d%d",&x,&y);
ans += min(a[x],a[y]);
}
printf("%lld\n",ans);
}

Codeforces Round #250 (Div. 1) A. The Child and Toy 水题的更多相关文章

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

  2. Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)

    Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...

  3. Codeforces Round #373 (Div. 2) C. Efim and Strange Grade 水题

    C. Efim and Strange Grade 题目连接: http://codeforces.com/contest/719/problem/C Description Efim just re ...

  4. Codeforces Round #185 (Div. 2) A. Whose sentence is it? 水题

    A. Whose sentence is it? Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

  5. Codeforces Round #373 (Div. 2) A. Vitya in the Countryside 水题

    A. Vitya in the Countryside 题目连接: http://codeforces.com/contest/719/problem/A Description Every summ ...

  6. Codeforces Round #371 (Div. 2) A. Meeting of Old Friends 水题

    A. Meeting of Old Friends 题目连接: http://codeforces.com/contest/714/problem/A Description Today an out ...

  7. Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题

    B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya ...

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

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

随机推荐

  1. How to Download APK Files from Google Play Store

    Evozi, an Android app developer, offers a one-click online APK download app that lets you download t ...

  2. Linux Kernel 4.8分支第4个候选版本发布

    导读 今天,大神Linus Torvalds宣布了Linux 4.8分支的第四个候选版本,该候选版本在提供常规驱动更新.架构改善和部分KVM调整之外最大的新功能就是修复了英特尔Skylake电源管理B ...

  3. [Papers]NSE, $\p_3u$, Lebesgue space [Cao, DCDSA, 2010]

    $$\bex \p_3\bbu\in L^p(0,T;L^q(\bbR^3)),\quad \frac{2}{p}+\frac{3}{q}=2,\quad \frac{27}{16}\leq q\le ...

  4. 六种排序的C++实现

    class SortNum { public: SortNum(); virtual ~SortNum(); void exchange(int& b,int& c);//交换数据 v ...

  5. Apache OFBiz 学习笔记 之 服务引擎 一

    概述     服务定义为一段独立的逻辑顺序,当多个服务组合一起时可完成不同类型的业务需求     服务有很多类型,WorkFlow.Rules.Java.SOAP.BeanShell等.java类型的 ...

  6. ARM指令集----杂项指令

    ARM指令集可以分为6类,即是跳转指令,数据处理指令,程序状态传输指令,Load.Store指令,协处理器指令和异常中断指令 跳转指令: 在ARM中有两种方式可以实现程序的跳转,一种是跳转指令,另一种 ...

  7. Multiclass Classification

    之前我们都是在Binary classification的基础上学习算法和知识. 如何使用Binary classification算法进行Multiclass classification呢? (一 ...

  8. 机器学习——Logistic回归

    参考<机器学习实战> 利用Logistic回归进行分类的主要思想: 根据现有数据对分类边界线建立回归公式,以此进行分类. 分类借助的Sigmoid函数: Sigmoid函数图: Sigmo ...

  9. <Chapter 2>2-2-2.开发Java应用(Developing a Java App)

    App Engine的Java网络应用使用了Java Servlet标准接口来和应用服务器交互.一个应用由一个或多个servlet类组成,每个都扩展了(extend)servlet基类.使用一个叫做部 ...

  10. Windows 窗体—— 键盘输入工作原理

    方法 注释 PreFilterMessage 此方法在应用程序级截获排队的(也称为已发送的)Windows 消息. PreProcessMessage 此方法在 Windows 消息处理前在窗体和控件 ...