意甲冠军:给定一个无向图,每个小点右键。操作被拉动所有点逐一将去,直到一个点的其余部分,在连边和点拉远了点,在该点右点的其余的费用。寻找所需要的最低成本的运营完全成本。

解法:贪心的思想,每次将剩余点中点权最大的点揪出,这样能够保证每条边都是会选择相对小的点权被消耗掉。所以直接输出全部边的边权和就可以。

代码:

/******************************************************
* author:xiefubao
*******************************************************/
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <string.h>
//freopen ("in.txt" , "r" , stdin);
using namespace std; #define eps 1e-8
const double pi=acos(-1.0);
typedef long long LL;
const int Max=10100;
const int INF=1000000007; int num[Max];
int n,m;
int main()
{
cout<<390/21.0<<endl;
while(scanf("%d%d",&n,&m)==2)
{
for(int i=1;i<=n;i++)
scanf("%d",num+i);
int ans=0;
for(int i=0;i<m;i++)
{
int a,b;scanf("%d%d",&a,&b);
ans+=min(num[a],num[b]);
}
cout<<ans<<endl;
}
return 0;
}

版权声明:本文博客原创文章。博客,未经同意,不得转载。

CF(437C)The Child and Toy(馋)的更多相关文章

  1. Codeforces 437C The Child and Toy(贪心)

    题目连接:Codeforces 437C  The Child and Toy 贪心,每条绳子都是须要割断的,那就先割断最大值相应的那部分周围的绳子. #include <iostream> ...

  2. codeforces 437C The Child and Toy

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  3. cf437C The Child and Toy

    C. The Child and Toy time limit per test 1 second memory limit per test 256 megabytes input standard ...

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

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

  6. Codeforces The Child and Toy

    The Child and Toy time limit per test1 second On Children's Day, the child got a toy from Delayyy as ...

  7. 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直接相连(且还未被移除)的部 ...

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

    之前一直想着建图...遍历 可是推例子都不正确 后来看数据好像看出了点规律 就抱着试一试的心态水了一下 就....过了..... 后来想想我的思路还是对的 先抽象当前仅仅有两个点相连 想要拆分耗费最小 ...

  9. The Child and Toy

    Codeforces Round #250 (Div. 2) C:http://codeforces.com/problemset/problem/437/C 题意:给以一个无向图,每个点都有一点的权 ...

随机推荐

  1. HDU 3360 National Treasures

    题目大意:大厅每个位置都有一个文物或者一个守卫,文物是安全的前提是: 关键位置上必须有一个守卫,或者文物本身的位置上有一个守卫.求保证每个文物是安全的守卫的最少数量. #include <cst ...

  2. mySQL中replace的用法

    MySQL replace函数我们经常用到,下面就为您详细介绍MySQL replace函数的用法,希望对您学习MySQL replace函数方面能有所启迪   mysql replace实例说明: ...

  3. 对象图(Object Diagram)—UML图(三)

    一.用一张图来介绍一下对象图的基本内容 二.对象图与类图的基本差别 三.对象图实例

  4. [LeetCode] Longest Substring Without Repeating Characters (LinkedHashSet的妙用)

    Given a string, find the length of the longest substring without repeating characters. For example, ...

  5. Two Sum-n方优化与C++map的使用

    LeetCode第一题,刚拿到题目时虽然明知道n方的遍历算法会超时,但还是不信邪的提交了一次,然而编程不存在运气,TLE不可避免.但是之后的思维方式比较直接,我并没有立刻想到O(n)的方法,想了一种先 ...

  6. JPEG概述和头分析(C源码)

    原创文章,转载请注明:JPEG概述和头分析(C源码)  By Lucio.Yang 部分内容来自:w285868925,JPEG压缩标准 1.JPEG概述 JPEG是一个压缩标准,又可分为标准 JPE ...

  7. JDBC_获取插入记录的主键值

    <span style="font-size:24px;">package src.com.JDBC2DAO.java; import static org.junit ...

  8. win7安装 Apache2.2 PHP5.3 MySQL5.6

    . APACHE2.2    经典参考资料 http://blog.csdn.net/yousuosi/article/details/9859507 官方下载地址  http://mirror.bi ...

  9. 文字适应DIV

    今天突然碰到了一个奇怪的问题  那就是对于纯数字和英文字母  文字多了会超出div  且即使是设置了height:auto overflow-y:auto 也不管用 只是在x轴上出现滚动条   不论用 ...

  10. STL string 模拟

    下面的代码来自c++ primer plus第5版第12章,书中代码写的非常好: // string1.h -- fixed and augmented string class definition ...