Codeforces Round #250 (Div. 2) 437C The Child and Toy(脑洞贪心)

别再只盯着FIFO深度了!Xilinx AXI Stream FIFO的TDATA、TUSER信号实战配置指南 本文深入解析Xilinx AXI Stream FIFO中TDATA与TUSER信号的高级应用,提供视频处理和数据流传输系统中的实战配置指南。通过详细讲解TUSER、TLAST等辅助信号的功能与配置方法,帮助工程师优化复杂系统的设计,提升数据处理效率与可靠性。 阅读详情

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

On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.

The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must remove all its parts. The child can remove a single part at a time, and each remove consume an energy. Let's define an energy value of part i as vi. The child spend vf1 + vf2 + ... + vfk energy for removing part i where f1, f2, ..., fk are the parts that are directly connected to the i-th and haven't been removed.

Help the child to find out, what is the minimum total energy he should spend to remove all n parts.

Input

The first line contains two integers n and m (1 ≤ n ≤ 1000; 0 ≤ m ≤ 2000). The second line contains n integers: v1, v2, ..., vn(0 ≤ vi ≤ 105). Then followed m lines, each line contains two integers xi and yi, representing a rope from part xi to part yi(1 ≤ xi, yi ≤ n; xi ≠ yi).

Consider all the parts are numbered from 1 to n.

Output

Output the minimum total energy the child should spend to remove all n parts of the toy.

Sample test(s)
input
4 3
10 20 30 40
1 4
1 2
2 3
output
40
input
4 4
100 100 100 100
1 2
2 3
2 4
3 4
output
400
input
7 10
40 10 20 10 20 80 40
1 5
4 7
4 5
5 2
5 7
6 4
1 6
1 3
4 3
1 4
output
160
Note

One of the optimal sequence of actions in the first sample is:

  • First, remove part 3, cost of the action is 20.
  • Then, remove part 2, cost of the action is 10.
  • Next, remove part 4, cost of the action is 10.
  • At last, remove part 1, cost of the action is 0.

So the total energy the child paid is 20 + 10 + 10 + 0 = 40, which is the minimum.

In the second sample, the child will spend 400 no matter in what order he will remove the parts.




一个礼物由n部分及m条绳子组成,每次拆掉一个部分有代价v,问你最小代价是多少。


看似麻烦的题,往往代码都短,每次都选出小的加起来就好了。。


AC代码:


#include "iostream"
#include "cstdio"
#include "cstring"
#include "algorithm"
using namespace std;
const int maxn = 1005;
int n, m, v[maxn];
int main(int argc, char const *argv[])
{
	cin >> n >> m;
	for(int i = 1; i <= n; ++i)
		cin >> v[i];
	int ans = 0, x, y;
	while(m--) {
		cin >> x >> y;
		ans += min(v[x], v[y]);
	}
	cout << ans << endl;
	return 0;
}


【点云可视化】自制ply文件并使用open3d可视化点云 使用open3d可视化点云,需要将点云制作为ply文件传入函数中。 安装open3d 直接使用pip安装 pip install open3d ply文件 ply文件的结构为:文件头+数据内容,文件头从 ply 一行开始,到 end_header 为止,里面定义了此 ply文件中数据的组织形式,包括数据类型和个数。后面是点云的坐标信息及每个点的颜色属性的,参考自 如下为具有5个点的点云,end_header后每一行表示一个点的x,y,z,R,G,B信息 ply format ascii 1.0 comme 阅读详情

相关推荐

第5.1节 构网控制:电压源特性与电压调节

摘要: 构网型变流器的核心物理本质是作为可控交流电压源,通过戴维南等效模型(受控电势源+低输出阻抗)自主建立并调节电压,增强电网电压刚度。其电压调节通过无功-电压闭环控制实现,内环为自动电压调节器(AVR),外环为无功-电压下垂特性,模拟同步发电机功能。关键技术包括自适应增益、虚拟阻抗补偿及动态限流策略,以应对弱电网稳定性、故障过流等问题。该设计满足《规范》对电压调节范围、动态无功支撑的要求,是高比例新能源电力系统电压稳定的关键解决方案。

技术工作者 1124

Codeforces Round #250 (Div. 2) C. The Child and Toy 详解

output standard output On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy. The toy consists of n parts and

__ElemenT 1506

探测器反向偏压_光探测器PN结原理

1 光探测原理在光的作用下,当光敏物质中的电子直接吸收光子的能量足以客服原子核的束缚时,电子就会从基态被激发到高能态,脱离原子核的束缚,在外电场作用下参与导电,因而产生了光电效应。(这里需要说明的是,如果光子不是直接与电子起作用而是能量被固体晶格振动吸收,引起固体的温度升高,导致固体电学性质的改变,这种情况就不是光电效应而是热电效应)。根据所用结的种类的不同,可分为PN结,PIN 结型,...

weixin_42489104的博客 2556

Codeforces Round #250 (Div. 1) A. The Child and Toy

A. The Child and Toy time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output On Children's Day, the child got a toy

flyljg的专栏 805

【RandLA-Net实战】从零构建隧道点云数据集并训练大场景语义分割模型

本文详细介绍了如何使用RandLA-Net构建隧道点云数据集并进行大场景语义分割模型训练。从数据采集、标注到模型训练与优化,提供了完整的实战指南,特别针对隧道场景的特殊挑战提出了解决方案。通过实际案例展示了RandLA-Net在处理大场景点云数据时的高效性和准确性,为隧道巡检等工程应用提供了可靠的技术支持。

weixin_30485379的博客 128

【CAPL实用开发】--- 使用VN1640A测试Busoff快慢恢复

使用VN1640A测试Busoff快慢恢复,包含具体的CAPL代码实现。

LabVIEW、CAPL、python、车载以太网等学习分享,文章正在写 2117

Children's Day

   Today is Childrens Day. What gift will I give children.   When we cheer this day , we are sad for our old now. Treasuring time is important for us. When we were chileren,we hoped that we could gro

【猩猩的专栏】 1362

自考计算机系统原理(第六章计算机系统概论)-13015

名词解释 I/O 硬件 I/O软件 用户空间I/O软件 内核空间I/O 软件 系统调用处理程序 系统调用服务例程 设备驱动程序 中断服务程序 系统级1/O函数 虚拟文件系统 文件描述符 文件元数据 流缓冲区 索引节点 目录文件 目录项 系统打开文件表 磁盘高速缓存 高速缓存 RAM I / O 控制方式 程序直接控制I/O 就绪状态 中断控制I/O 中断屏蔽字 多重中断 中断嵌套 DMA 方式 DMA 控制器 设备控制器 I/O端口 控制端口 数据端口 状态端口 I/O 地址空间 独立编址方式 统一编址方

qq_23872947的博客 1161

The Child and Toy

On Children’s Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can’t wait to destroy the toy. The toy consists of n parts and m ropes. Each rope links two p...

eazo的博客 409

第1讲|AI产品经理全景图谱:不是“会用AI工具”,而是能对AI产品结果负责

本文从岗位本质出发,系统拆解 AI 产品经理的职责、岗位类型与能力模型,帮助读者理解 AI PM 与传统 PM 的核心差异,明确自己适合的转型方向,并建立“对 AI 产品结果负责”的产品认知。

从零开始,掌握网络安全。提供全面的网络安全教程、攻防演练技巧和行业动态。 1035

把外部系统一键装进 SAP Build Work Zone:从零开始创建 HTML5 URL App

HTML5 URL App 是一种轻量级解决方案,可将外部网页或系统入口快速集成到SAP企业门户中。开发者只需在manifest.json中配置目标URL、导航模式等参数,无需开发完整前端应用。该方案利用SAP BTP的HTML5 Application Repository集中存储静态资源,通过HTML5 Apps Content Provider将应用暴露给子账号,最终在SAP Build Work Zone中以Fiori磁贴形式呈现。文章详细介绍了manifest.json的关键配置、三种基础设施组件

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 260

Codeforces 437C The Child and Toy 简单图论贪心

C. The Child and Toy time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output On Children's Day, the child got a toy

J. Cole 692

深度学习在移动开发中的应用:实时姿态估计实战

我们将使用TensorFlow Lite框架,结合专为移动端优化的MoveNet模型,实现一个能够在主流Android设备上达到30FPS的多人姿态跟踪解决方案,并深入探讨其优化技巧和实际应用场景。特别是3D姿态估计、多人长期跟踪等前沿技术的发展,将进一步推动移动端姿态估计技术的应用深度和广度。在下一篇文章中,我们将探讨深度学习在移动端的另一个创新应用:实时手势识别,包括如何在资源受限的环境中实现复杂手势的实时识别,以及这项技术在AR/VR交互、智能家居控制等场景中的应用。第四部分:典型应用场景实现。

Programming Talk 331

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 standard input output standard output On Children's Day, the child

Sun_tester的专栏 1803

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

**Codeforces Round #250 (Div. 2) C. The Child and Toy ACM解题报告(贪心难题)

今天是惨遭吊打,和学长做去年的儿童节专场,只做出来A题,B题直接暴力以为会超时,dp了半天过不了,C题贪心贪错了。。。 这题的大意是有n个部件,要把他们全部破坏,破坏i就需要与i相连的那些部件的能量,比如j,k与i相连,破坏i就需要vj+vk的能量,求全部破坏需要多少能量。 我也是太年轻,直接按照每个部件拆除所需能量升序排序,然后拆能量需要最小的。 这个方法的错误在于,也许有几次拆的时候,消

Miracle_ma的专栏 770

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Codeforces Round #250 Div1A Div2C 437C The Child and Toy 贪心

这道题我在考场上并不是自己想出来的,是在别人帮助下搞懂的。

KuribohG 1016

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

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 standard input output standard output On Children's Day, the child got a toy

守护生命的绿荷的专栏 417

Codeforces Round #250 (Div. 2)C. The Child and Toy(贪心)

传送门 Description On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy. The toy consists ofnparts andmropes. ...

weixin_30466039的博客 132

H - The Child and Toy-CodeForces 437C-水题

这题看懂了直接 输出一条边中比较小的那个点的权值即可。。。当时没想到,一股脑就当成图去贪心了,所以复杂多了   #include #include #include #include #include #include #include using namespace std; // 邻接表vector实现 struct node { int val; int

缺氧 791

CF 437C The Child and Toy

http://codeforces.com/problemset/problem/437/C time limit per test 1 second memory limit per test 256 megabytes input: standard input output: standard output Description On Children’s Day, t...

tangzhide123yy的博客 326

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/problem/A Description On Children's Day, the child got a toy from Delayyy as a prese...

weixin_34220834的博客 149

Codeforces 437C The Child and Toy

On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy. The toy consists of n parts and m ropes. Each rope links

XDU_PYL的博客 591

CodeForces - 437C The Child and Toy (贪心)

The Child and Toy On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy. The toy consists ofnparts andmropes...

YOONGI 456

Codeforces Round #321 (Div. 2) 580C Kefa and Park(dfs)

题目链接: 第一行给你n、m,接下来的一行有n个数,如果为1则代表这个点有cat,接下来的n-1行每行给出x、y,表示x、y相连。问你从1出发 能到达的叶子结点有几个,要求到达叶子结点的路上连续有cat的点不超过m。 a数组保存结点是否含有cat,从1这个点开始dfs,每次dfs对cat数组操作,记录连续的含有cat的点数,回溯时再判断当前结点是否满足 条件,要求结点为叶子

GKHack's Blog 2045

Codeforces Round #200 (Div. 2)344E Read Time(二分)

E. Read Time time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike does not use slow hard disks

GKHack's Blog 1750

Codeforces Round #325 (Div. 2) 586ABC题解

题目链接:点击打开链接 A: 给出Alena的课表, 1代表有课, 0代表没课, 2个连续0以上可以回家休息, 问你一天在学校待多久. 直接模拟即可, 可以直接计算1, 101的数目. 我记录了开头的1和结尾的1, 然后减去2个连续0以上的个数就是答案. AC代码: #include "iostream" #include "cstdio" #include "cstring" #

GKHack's Blog 1713
上一篇: Codeforces Round #250 (Div. 2) 437A The Child and Homework(模拟)
下一篇: POJ1195 Mobile phones(树状数组)
GKHack
博客等级 码龄12年 48粉丝 291原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址