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;
}


【论文复现】自动化细胞核分割与特征分析 HoVer-Net是一种精心设计的多分支深度学习网络架构,专为处理复杂的多组织显微图像中的细胞核实例分割与精确分类任务而开发。该网络通过创新的策略,不仅有效解决了细胞核在密集聚集区域难以准确区分的问题,还实现了对每个独立细胞核类型的细致分类。此外,HoVer-Net还引入了专门的上采样分支,这一设计旨在对每个成功分割出的细胞核实例进行进一步的核类型分类。这一分支利用高级语义信息,结合精心设计的分类策略,能够准确判断每个细胞核的所属类型,为医学研究提供了宝贵的细胞水平信息。 阅读详情

相关推荐

基于python获取网易云热门歌单及封面

先看一下图片背后的代码 非常好,里面歌单名字,id,以及封面图片都有了.在复制url的时候注意把/#删掉,要不然爬不了. import requests from lxml import etree url='https://music.163.com/discover/playlist' head={ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Ch

ziyuan12345678的博客 536

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的专栏 804

STM32CubeMX + HAL库避坑指南:为什么你的代码总在SystemClock_Config卡住?

本文深入剖析了STM32开发者在使用STM32CubeMX和HAL库时,代码在SystemClock_Config函数中卡死的根本原因。文章不仅指出硬件时序、Flash延迟配置等常见陷阱,更提供了从硬件设计、软件容错到深度调试的系统性解决方案,帮助开发者构建鲁棒的时钟初始化策略,彻底告别启动卡顿问题。

bb456的博客 928

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

影刀RPA进阶:Excel多条件筛选与数据提取实战

本文详细介绍了如何利用影刀RPA实现Excel多条件筛选与数据提取的自动化。通过拆解文本、数值、日期及颜色筛选等核心指令,并结合实战案例,指导用户构建稳健的销售数据提取机器人,从而高效处理复杂数据报表,提升工作效率。

onion的博客 530

创建可视化机房

(3)窗户位置创建好以后需要对窗户的墙面镂空位置进行修补,具体操作为,选中镂空位置的顶点(这里必须是选择一个平面的顶点,不要跨平面选择),实际操作如下图:选择点以后,鼠标右键,选择【从顶点创建边/面】,或者按F键,随后对其他镂空位置进行相同操作;(2)将【物体模式】修改为【编辑模式】,选中-x对应面的所有顶点,移动顶点位置,其他放小调整按照同理,找到选中对应面的所有顶点,移动位置即可;调整动画事件轴上的线,选中关键帧的时间,调整模型的位置或者旋转角度,具体根据插入关键帧菜单选择的项进行模型的相关调整。

SmileBu丿㦌的博客 2067

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 1504

通过轻量级图像增强Transformer (IAT) 提升YOLOv8在低光环境下的检测性能

随着深度学习和计算机视觉的快速发展,目标检测模型在各个领域中的应用不断扩展,特别是在低照度环境下的视觉任务。YOLOv8作为当前最先进的目标检测模型之一,在高亮度和良好照明条件下表现出色,但在低照度环境下的性能存在一定的不足。为了解决这一问题,我们提出了一种轻量级的低照度图像增强网络(IAT)来改进YOLOv8的暗光检测能力。本篇文章将深入探讨这一创新改进,并附带代码实现,帮助大家更好地理解这一技术的应用和效果。

博客 1214

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 455

【Unity】RPG2D龙城纷争(十九)流程与UI界面(终章)

本章为RPG2D系列的终章,在之前的章节中我们已经完成了游戏的所有基本功能,那么用流程与UI界面将其串联起来才是我们整个游戏原型完善的标志。

神码编程 917

【PCIe 总线及设备入门学习专栏 6.2 -- PCIe VDM (Vendor Defined Messages)】

在PCIe协议中,Vendor Defined Messages (VDMs) 是一种允许厂商定义和传输特定功能的消息类型。这种机制扩展了标准 PCIe 消息的功能,可以用于实现供应商自定义的功能,例如固件更新、设备配置和诊断信息传输。PCIe VDM 是通过实现的,它遵循 PCIe 协议栈的结构,包括事务层、数据链路层和物理层。

CodingCos的博客 1896

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的专栏 1801

【心电信号】基于多种滤波去除心电信号基线漂移含Matlab源码

1 简介 心电信号可以用来检测和诊断心脏疾病,心电信号在采集时经常受到呼吸活动、身体运动和皮肤与电极接触不良等影响,因此会产生基线漂移,基线漂移的存在会降低心电信号的质量。所以,在大多数心电信号处理中,包括心律失常的识别、心率变化分析和连续血压测量等,去除基线漂移成为了至关重要的一步。心电信号具有非平稳、非线性的特性,传统的去除心电信号中基线漂移的方法在对心电信号进行去噪时常因去噪过度或者不完全,容易造成大量非线性特征信息的丢失,从而破坏了心电信号本身的动力学特性,这给后续的心电信号信息分析带来了不利影响

qq_59747472的博客 2209

**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的专栏 769

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

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

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

KuribohG 1016

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

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

守护生命的绿荷的专栏 415

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

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的博客 131

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的博客 589

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的博客 323

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 691

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的博客 408

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

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

缺氧 786

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 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 2041

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 1749

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

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值