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 题意:给以一个无向图,每个点都有一点的权 ...
随机推荐
- android 同时发送几条通知
android 同时发送几条通知 ======= 下面是转载的文章. 同时发送几条通知把ID添加,接收的时候找到这个id就可以出来多条了. 还是不太明白或者编码实现不了的可以加我QQ. 博客很少上 ...
- Lua学习笔记5:类及继承的实现
-- Lua中类的实现 -------------------------------- 基类 ---------------------------- classBase = {x = 0,y = ...
- 深入理解java嵌套类和内部类
一.什么是嵌套类及内部类 能够在一个类的内部定义还有一个类.这样的类称为嵌套类(nested classes),它有两种类型:静态嵌套类和非静态嵌套类.静态嵌套类使用非常少,最重要的是非静态嵌套类,也 ...
- linux进程间通信之信号
1.wait()函数 原型:pid_t wait(int *status) 子进程退出时,它向父进程发送一个SIGCHLD信号,默认情况是总是忽略SIGCHLD信号,此时进程状态一直保留在内存中,因 ...
- ASP.NET中IsPostBack的理解
IsPostBack是Page类的一个属性,返回值为一个布尔值. 一般放在Page_Load事件中, 是指是否第一次调用这个页面.当页面是第一次打开时其值为False,若当前页面为一个提交后的页面其值 ...
- iOS开发之第三方分享QQ分享,史上最新最全第三方分享QQ方式实现
本文章源码地址: https://github.com/zhonggaorong/QQLoginDemo 项目搭建参考: (包含QQ登录源码下载 . QQ sdk集成) http://blog.cs ...
- Python学习之路——函数
一.Python2.X内置函数表: 注:以上为pyton2.X内置函数,官方网址:https://docs.python.org/2/library/functions.html 二.Python3. ...
- poj 3286 统计0的个数
#include <iostream> using namespace std; long long p; ]; long long solve(long long n){ ; ;i< ...
- asp.net mvc 客户端(&)中检测到有潜在危险的 Request.Path 值。
出现这个错误后,试过 <pages validateRequest="false"> <httpRuntime requestValidationMode=&qu ...
- known good die( KGD) /确认好裸芯片,合格芯片
英文:known good die( KGD) / 中文:确认好裸芯片,合格芯片 完工的晶圆上有许多晶片存在,其单一品质有好有坏,经过老化试验后,其确知电性能良好的晶片即称为己知好晶片.不过,已知好晶 ...