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 题意:给以一个无向图,每个点都有一点的权 ...
随机推荐
- BZOJ 1096
const maxm=1e100; maxn=; ..maxn] of int64; q:..maxn] of longint; n,i,h,t:longint; function calc(j,i: ...
- File,FileInputStream,FileReader,InputStreamReader,BufferedReader 的使用和区别
1 ) File 类介绍 File 类封装了对用户机器的文件系统进行操作的功能.例如,可以用 File 类获得文件上次修改的时间移动, 或者对文件进行删除.重命名.换句话说,流类关注的是文件内容,而 ...
- 使用mongodb存取lbs数据
1,在mongodb中创建lbs_db数据库,collection名称lbs_info,要使用lbs查询功能,需要对二维数据列建立索引 db.lbs_info.ensureIndex( { locs ...
- boost::string or boost::regex
有时候写代码时会遇到下面问题 如果有一个文本文件,其包括内容类似于C语言,当中有一行例如以下格式的语句: layout (local_size_x = a,local_size_y = b, loca ...
- bootstrap固定响应式导航
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap. ...
- 【转】emulator: ERROR: Could not load OpenGLES emulation library: lib64OpenglRender.so
[转]emulator: ERROR: Could not load OpenGLES emulation library: lib64OpenglRender.so ./emulator64-arm ...
- Oracle_sqlload导数案例
文件地址:http://115.com/lb/5lbbut5jc6op 案例中的sql_load导数公用到5个文件,分别是bat.ctl.txt.log.bad 5个文件 bat文件: --用户名/用 ...
- javaEE的13种核心技术规范
javaEE平台由一整套服务(Services).应用程序接口(APIs)和协议构成,它对开发基于Web的多层应用提供了功能支持,下面对javaEE中的13种技术规范进行简单的记录: J2EE中的 ...
- Java学习之位运算和逻辑运算符
今天看了一下HashMap类的源码,在HashMap的源码中定义了初始空间的大小 static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; 当 ...
- 驱动: i2c驱动 >>>>
1. IIC协议: <<um_s3c2440a_rev10.pdf>> p481 Figure 20-3. IIC-Bus Interface Data Format< ...