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


YOLOv11改进策略【卷积层】| CVPR-2023 部分卷积 PConv 轻量化卷积,降低内存占用 本文记录的是利用优化的目标检测方法研究。深度可分离卷积可以减少FLOPs,但会导致更高的内存访问,引起延迟并减慢整体计算。部分卷积利用逐点卷积处理通道冗余,减少模型计算量和内存访问量。Run, Don’t Walk: Chasing Higher FLOPS for Faster Neural Networks的实现代码如下: 四、创新模块 4.1 改进点⭐ 模块改进方法: 1️⃣ 加入。添加后如下:2️⃣:加入基于的。利用改进模块,减少通道冗余。改进代码如下:首先添加如下代码让加入,并重命名为 再添加如 阅读详情

相关推荐

Unity——Scroll View 滑动居中、居中的放大、其他的缩小(支持横竖Scroll View)

一、效果 二、上代码,两种方式。 (第一种是在Update中用插值完成的,如果不想再项目中看到Update,下面的另一种改了一段用DoTween实现的,需要导入一下DoTween) using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using Unit...

SiReSo 7659

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

核磁分析必备,ACD/Labs软件使用全解析

核磁共振(NMR)是化学分析中的重要工具,而ACD/Labs提供了一套强大的软件解决方案。从实验设计到数据解读,ACD/Labs 的 NMR 预测可以显著加快您的工作流程。使用 ACD/NMR 预测可以:根据化学结构预测 1H、13C、15N、19F 和 31P 核的全套 1D 和 2D NMR 光谱;在几秒钟内计算化学位移和耦合常数;利用内部数据训练算法,提高新化学空间的准确性。

a13981820402的博客 5635

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

CANdelaStudio实战:如何用19服务快速编辑DTC快照数据(附Excel模板)

本文详细介绍了在CANdelaStudio中利用19服务高效编辑DTC快照数据的进阶技巧。通过导出DTC池至Excel进行批量编辑,结合‘Copy from DTC Pool’功能实现配置复用,并分享了构建自定义Excel模板与字段映射的实用方法,帮助工程师将繁琐的手动配置转化为工程化的批量处理,大幅提升诊断数据库开发效率。

weixin_29230773的博客 191

Foxglove 介绍以及入门使用教程

Foxglove 是由Foxglove 工作室开发的一套工具集,包括和等组件。跨平台支持:可以在 Windows、macOS 和 Linux 上运行。多协议兼容:支持 ROS、ROS 2、CAN 数据以及其他自定义协议。丰富的可视化功能:可以绘制点云、轨迹、激光雷达数据、IMU 数据等。实时与离线模式:既可以实时监控机器人状态,也可以加载和回放记录的数据文件。Foxglove 的 3D 视图允许你以三维方式查看机器人的运动轨迹、传感器数据和其他几何信息。你可以旋转、缩放和平移视图以获得更好的观察角度。

zolty 1万+

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

机器人轨迹规划——三次样条轨迹1(基于速度的求解方法)

三次样条轨迹是利用三次样条曲线来对给定的一系列点进行插值,从而得到一个光滑的轨迹。三次样条因为每段的多项式次数最高都是三阶的,所以可以得到2阶导数连续,也就是加速度连续的轨迹。假设给定了一系列的点q0q1q2qnq0​q1​q2​...qn​,以及每个点对应的参数t0t1t2tnt0​t1​t2​...tn​,计算一条三次样条曲线sts(t)st,该曲线通过给定的点q0q1q2qnq0​q1。

出门搔白首,若负平生志 1471

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

Codex入门00-初识神器(小白入门:到底什么是Codex CLI,和ChatGPT写代码有什么不同?)

OpenAI Codex CLI 是 OpenAI 于2025年推出的终端原生AI编程代理,不是在网页里聊天写代码,而是直接在你的终端里自主读代码、改文件、跑命令。它拥有三种安全模式、/goal 持久化任务、云端沙箱执行等独特能力。本文从零介绍 Codex CLI 的核心概念、与 ChatGPT 写代码的本质区别、典型使用场景和费用说明,让你全面认识这个改变开发方式的神器。

yueyeguzhuo的专栏 302

如何正确的计算两个角度的角度差?

这一步是必要的,因为它确保了无论a相对于b是在逆时针方向还是顺时针方向,d2总是正确地反映出绕圆相反方向的角度差。这样,当函数进行最后的比较时,它能够准确地比较两个方向的旋转路径并选择最短的一个。

小秋 AI SLAM 入门实战教程 4137

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

Android 13.0 SystemUI下拉状态栏背景增加高斯模糊背景

在13.0的产品开发中,发现现在很多产品都是高斯模糊背景的,这种高斯模糊背景看起来效果很不错,产品开发需要SystemUI下拉状态栏背景也是高斯模糊背景,所以就要来实现下拉状态栏高斯模糊背景

安卓兼职framework和app工程师的博客 2670

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

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

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

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

KuribohG 1016

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

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

数学建模模型总结

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

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、付费专栏及课程。

余额充值