CF(437C)The Child and Toy(馋)
意甲冠军:给定一个无向图,每个小点右键。操作被拉动所有点逐一将去,直到一个点的其余部分,在连边和点拉远了点,在该点右点的其余的费用。寻找所需要的最低成本的运营完全成本。
解法:贪心的思想,每次将剩余点中点权最大的点揪出,这样能够保证每条边都是会选择相对小的点权被消耗掉。所以直接输出全部边的边权和就可以。
代码:
/******************************************************
* 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(馋)的更多相关文章
- Codeforces 437C The Child and Toy(贪心)
题目连接:Codeforces 437C The Child and Toy 贪心,每条绳子都是须要割断的,那就先割断最大值相应的那部分周围的绳子. #include <iostream> ...
- codeforces 437C The Child and Toy
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- cf437C The Child and Toy
C. The Child and Toy time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 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(C.The Child and Toy)
题目例如以下: C. The Child and Toy time limit per test 1 second memory limit per test 256 megabytes input ...
- 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 ...
- 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直接相连(且还未被移除)的部 ...
- Codeforces #250 (Div. 2) C.The Child and Toy
之前一直想着建图...遍历 可是推例子都不正确 后来看数据好像看出了点规律 就抱着试一试的心态水了一下 就....过了..... 后来想想我的思路还是对的 先抽象当前仅仅有两个点相连 想要拆分耗费最小 ...
- The Child and Toy
Codeforces Round #250 (Div. 2) C:http://codeforces.com/problemset/problem/437/C 题意:给以一个无向图,每个点都有一点的权 ...
随机推荐
- APUE学习之---------------进程
离职了,交接期也有足够的时间了,可以在好好的再看一下APUE,想想上次详细的看还是在两年之前,虽然中间也偶尔会翻出来看看,但是由于工作上交集相对比较少一直没有去细读一下.现在正好是一段空挡期可以好好看 ...
- ACM—循环小数转变成分数知识点_C++实现
在小学的时候,我们的学生都能把“整数表示成分母是1的分数”,而且大多数学生也都能把有限小数和循环小数表示成分数的形式.这样,整数.分数.有限小数.循环小数都属于有理数.教科书中说“整数和分数统称有理数 ...
- hdoj 1874 畅通工程续(单源最短路+dijkstra)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1874 思路分析:该问题给定一个无向图.起始点和终点,要求求出从起始点到终点的最短距离: 使用Dijks ...
- 开发板-PC机(宿主机)-虚拟机(VM)之间网络通信设置方法及须要注意的问题
1.不使用路由器交换机 硬件连接: 使用网线将开发板和PC机相连 串口线将PC机和开发板相连 使用命令: ifconfig -a 串口控制端查看开发板的网络配置 route -n 串口控制端查看开发板 ...
- C# ikvm 运行htmlunit Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl not found
在使用 ikvm 去运行 htmlunit 中的 webclient Getpage的时候 报错说com.sun.org.apache.xerces.internal.jaxp.DocumentBu ...
- 经典排序算法及python实现
今天我们来谈谈几种经典排序算法,然后用python来实现,最后通过数据来比较几个算法时间 选择排序 选择排序(Selection sort)是一种简单直观的排序算法.它的工作原理是每一次从待排序的数据 ...
- .net EF中从数据添加表或视图时无法添加的问题
.net 使用EF模式进行开发,添加实体时不能够正常添加 错误描述: .net中在EF文件中添加数据库中已有的表或视图时不能正常添加,在添加时没有任何的错误提示,但是表或视图就一直拉不过来,,保存也没 ...
- (待解决问题)nowrap在table和td都设置了宽度的时候仍然有效
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- hdu1695 GCD
http://acm.hdu.edu.cn/showproblem.php?pid=16951 /** 大意: a<=x<=b , c<= y <= d ,求在此范围内 有多少 ...
- IE读取并显示本地图像文件的方法
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...