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 题意:给以一个无向图,每个点都有一点的权 ...
随机推荐
- java循环HashMap两种方法的效率比较
一.循环HashMap的两种方式 方式1: Iterator<Entry<String, String>> entryKeyIterator = entrySetMap.ent ...
- < high performance web sites > 阅读小记
high performance web sites 1,减少HTTP请求数 (1)图片加载使用image maps 或者 CSS Sprite (2)使用非http协议,如(ftp:, file: ...
- Java-线程间通信
Java-线程间通信 一 线程通讯 就是多个线程操作同一个资源,可是操作的动作不同 二 停止线程: 控制住run的循环就能够控制线程结束 当线程处于冻结状态,就不会读取标记,线程就不会结束 inter ...
- c 对某个整数做因式分解
1 #include <stdio.h> int main(void) { int n,i; scanf("%d",&n); printf("%d=& ...
- C#中文件管理的运用(Twelfth Day)
又到了总结的时间了,今天在云和学院学习了文件管理的一些运用及复习昨天学的里氏转换.今天我就总结下昨天遗留下的问题以及今天所学的知识. 昨天遗留的问题 里氏转换(父类转子类) 例:在这里定义父类Peop ...
- if和switch的区别,循环的for 和while的区别, 字符串常用的7种方法
相同点: 都是用于多重选择 不同点: 多重IF没有switch选择结构的限制,特别适合变量处于某个连续区间的情况 switch只能处理等值条件判断的情况,而且条件必须是整型变量或者字符串变量 字符串的 ...
- BZOJ 1864: [Zjoi2006]三色二叉树( 树形dp )
难得的ZJOI水题...DFS一遍就行了... ----------------------------------------------------------------------- #inc ...
- PHP 判断数据类型
isset()://变量是否已经声明 empty()://变量是否为空 defined()://常量是否已经定义 define() array_key_exists(mixed key, array ...
- dede修改移动文档的js
dede后台弹框修改: 想做个类似文章列表的移动功能,弹框,然后修改成功到表 先在list.js里复制一份moveArc的方法,到archives_do.php里复制一份moveArchives的方法 ...
- hdu 4180
题意; 求接近规定 分数 的 最大分数用到 farey 数列的第二条性质 1 #include <iostream> #include<stdio.h> using names ...