Codeforces Round #252 (Div. 2) B. Valera and Fruits(模拟)

Index-TTS-1.5:多模态语音合成的技术演进与商业落地实践 本文深入探讨了Index-TTS-1.5在多模态语音合成领域的技术演进与商业落地。该模型基于GPT风格的自回归Transformer架构,通过优化条件编码器和引入字符-拼音混合建模,显著提升了语音生成的稳定性、精准度和真实感,实现了高质量的零样本语音克隆。文章还详细介绍了其云端体验、本地WebUI部署及ComfyUI集成等实战路径,并分析了其在虚拟数字人、个性化内容创作等商业场景中的应用潜力与挑战。 阅读详情

B. Valera and Fruits
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Valera loves his garden, where n fruit trees grow.

This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).

Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more thanv fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well?

Input

The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day.

Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi(1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree.

Output

Print a single integer — the maximum number of fruit that Valera can collect.

Sample test(s)
input
2 3
1 5
2 3
output
8
input
5 10
3 20
2 20
1 20
4 20
5 20
output
60
Note

In the first sample, in order to obtain the optimal answer, you should act as follows.

  • On the first day collect 3 fruits from the 1-st tree.
  • On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree.
  • On the third day collect the remaining fruits from the 2-nd tree.

In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither.


题目链接:http://codeforces.com/contest/441/problem/B


题目大意:有n棵果树和每天最大的水果采摘量v,每棵果树有对应的采摘日期day,只能在day和day+1两天采摘,求最终水果的最大采摘量。


解题思路:对每棵果树的采摘日期从小到大排序,日期靠前的先采摘。


代码如下:

#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
int const maxn=300005;
struct A
{
    int d,b;
}a[3005];
int cmp(A p,A q)
{
    return p.d<q.d;
}
int main()
{
    
    int n,v,ans=0;
    scanf("%d%d",&n,&v);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&a[i].d,&a[i].b);
    }
    sort(a+1,a+n+1,cmp);
    for(int day=1;day<=maxn;day++)
    {
        int cur=0,p=0;         //cur为每天的采摘量
        for(int i=1;i<=n;i++)
        {
            if(a[i].d>day)     //如果还未到达当前果树的日期,后面果树的日期也未到达,结束当前循环
                break;
            if(a[i].d!=day&&a[i].d+1!=day)
                continue;
            if(a[i].b>0)        //在规定的两天日期可以采摘
            {
                p=1;
                if(a[i].b+cur<=v)  //a[i].b表示当前果树上果实个数,如果采摘数量会有更新
                {
                    cur+=a[i].b;
                    a[i].b=0;
                }
                else
                {
                    a[i].b-=(v-cur);
                    cur=v;
                    break;
                }
            }
        }
        ans+=cur;
        if(a[n].d+1<day)
            break;
    }
    printf("%d\n",ans);
    return 0;
} 


数字IC设计实现之hierarchical flow系列(一) 数字IC设计实现之hierarchical flow系列(一) 最近这段时间小编又比较忙起来了,今天抽空来咖啡厅码字来了,刚到时脑子一片空白,不知道要分享些什么(项目结束后将会在知识星球上分享数字 IC 设计实现 Tapeout 前要review的那些 checklist)。突然间想起来有个星友希望小编分享些数字 IC 设计实现 hierarchical flow 的相关内容。考虑到现在大都采用这种方式来做 design 和实现,那就选这个 topic 了。限于篇幅和时间限制,今天只分享逻辑综合部分和布局布 阅读详情

相关推荐

别再只用相机标定了!手把手教你用OpenCV和Python搞定投影仪标定(附完整代码)

本文详细介绍了如何使用Python和OpenCV实现投影仪标定,特别针对结构光三维扫描中的核心问题。通过低成本替代方案和优化算法,解决投影仪标定中的非线性畸变和亮度-距离耦合效应,显著提升三维重建精度。附完整代码和实战技巧,帮助开发者快速掌握关键技术。

weixin_29274337的博客 548

Valera and Fruits(贪心)

B. Valera and Fruits time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Valera loves his garden, where n fruit trees g...

Simone chou... 156

TongWeb微服务部署实战:Nacos注册与网关路由的疑难解析

本文分享了将Spring Cloud微服务迁移至TongWeb应用服务器时,解决Nacos服务注册失败与Spring Cloud Gateway路由失效的实战经验。针对Nacos注册问题,通过实现ApplicationRunner接口并利用JMX获取容器端口,实现了手动注册;针对网关路由问题,建议将基于WebFlux的Gateway模块改为JAR包独立部署,以保障其原生运行环境。文章为在TongWeb上进行微服务部署提供了关键的问题排查思路与混合架构部署的最佳实践。

weixin_29209801的博客 247

Codeforces Round #252 (Div. 2)B. Valera and Fruits

#include #include using namespace std; #define inf 0x3f3f3f3f int main() { int n,m,a,b; int s=0; int t[3111]; memset(t,0,sizeof(t)); cin>>n>>m; int maxt=0; for(int i=0;i<n;i++)

smz436487的专栏 731

高分六号GF-6 WFV数据处理全流程:从原始数据解压到经纬度投影转换

本文详细解析了高分六号GF-6 WFV遥感数据的完整处理流程。从原始数据解压与分块结构理解入手,指导如何安装ENVI国产卫星支持工具进行自动拼接,并重点阐述了利用RPC模型进行正射校正以消除几何畸变,以及将UTM投影转换为地理经纬度坐标的关键步骤。文章旨在帮助用户高效地将原始卫星数据转化为可直接用于农业监测、生态环境分析等领域的标准地理空间图像。

weixin_29047919的博客 201

【Matterport3D模拟器安装详细教程】适用于离散视觉语言导航任务的环境部署与安装

请注意,本文特指在环境下的安装!

六六六六神的博客 6800

Codeforces Round #521 (Div. 3) ABCDEF1F2总结

要是C没挂终测,我这场就。。。没有什么要是。C题读错题了。终测前6道rk47,终测完5道rk140。虽然上了86分,但是心里还是很sad。。。 A题: 没什么好说的。统计1~k的奇数和偶数个数。答案就是n*((k+1)/2)-(m*(k/2))。 B题: 考虑贪心,每次出现“101”这种情况我们就把后面的1改成0。这样10101这种情况我们只需要改一个,肯定是最优的。 C题: 这道题我...

LSD20164388的博客 442

【ComfyUI】QwenImageEdit + Z-Image 面部融合图生图

本文介绍了一种基于Stable Video Diffusion(SVD)模型的ComfyUI图生视频工作流,能够将静态图片转换为动态视频。工作流包含模型加载、图像导入、条件生成、视频采样、解码合成等8个核心步骤,通过SVD_img2vid_Conditioning节点实现视觉语义转换。该方案适用于创意视频制作、产品演示等场景,支持设计师和AI爱好者快速实现"以图生动"效果。文中详细说明了工作流架构、关键节点功能、操作流程及应用案例,并提供了模型参数和使用注意事项。

Mr数据杨 1846

codeforces252-B - Valera and Fruits

#include #include #include #include #include #include #include #include #include #include #include #include #include #define Maxn 3005 typedef long long ll; #define rep(i,j,n) for(int i=j;i<=n;i+

Griffin_0的专栏 548

使用 syncstart 实现同场景下多个音视频音轨自动化同步

如果需要在视频编辑中同步多个机位的音轨,使得相同的视频能够同时播放,手动操作可能会变得相当复杂。特别是当处理多个视频文件时,例如有10个视频需要互相匹配,实现一对多的同步关系,这就涉及到为每对视频生成匹配的音轨数据。手动完成这样的任务,如生成90套对应的音轨数据,不仅耗时而且容易出错。因此,使用脚本自动化这一过程是一个更为高效和准确的解决方案。通过编写脚本,您可以批量处理多个视频文件,自动同步它们的音轨,大大简化了音视频编辑的工作流程,并确保了同步的准确性。

Mr数据杨 1087

多源异构数据融合(Kaggle+Google Trends联合分析)

本文详细介绍了如何利用Python实现多源异构数据融合,以Kaggle电商销售数据与Google Trends搜索指数为例,展示了数据清洗、预处理、时间对齐、数据合并、相关性分析、回归建模和可视化全过程。数据预处理与内存优化通过分块加载、数据类型转换和缺失值处理,有效降低了大规模数据在内存中的占用,并确保数据质量。时间对齐与数据融合策略采用重采样与内连接方法对齐不同数据源的时间维度,实现了高质量数据的融合,为后续联合分析奠定基础。模型构建与分析。

闲人编程的博客 1025

codeforces-Valera and Fruits

http://codeforces.com/contest/441/problem/B 题目大一

qqcyclone的专栏 663

【国产MCU】-认识CH32V307及开发环境搭建

CH32V307是[沁恒](https://www.wch.cn/)推出的一款基于32位RISC-V设计的互联型微控制器,配备了硬件堆栈区、快速中断入口,在标准RISC-V基础上大大提高了中断响应速度。加入单精度浮点指令集,扩充堆栈区,具有更高的运算性能。扩展串口UART数量到8组,电机定时器到4组。提供USB2.0高速接口(480Mbps)并内置了PHY收发器,以太网MAC升级到千兆并集成了10M-PHY模块。

视觉与物联智能 2355

Codeforces Round #252(Div. 2) 441B. Valera and Fruits 贪心

B. Valera and Fruits time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Valera loves his garden, where n fruit

Jonariguez 吾本优秀 810

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

Codeforces Round #252 (Div. 2)-B. Valera and Fruits

题目: 题意:

Halo 725

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

Codeforces Round #252 (Div. 2) 441B. Valera and Fruits

英语不好就是坑啊。这道题把我坑残了啊。5次WA一次被HACKA

veritaswu的专栏 1053

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

Codeforces Round #252 (Div. 2) B. Valera and Fruits

Let's start counting days from 1 to 3001. Let current day be i. Additionally, we'll have cur variable — number of fruit we didn't collect previous days. Suppose now fruit is ripen current day. If no

守护生命的绿荷的专栏 415

A - Valera and Fruits

Valera and Fruits

Yuric的专栏 521

noj 1046 第K回文数

欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦: Markdown和扩展Markdown简洁的语法 代码块高亮 图片链接和图片上传 LaTex数学公式 UML序列图和流程图 离线写博客 导入导出Markdown文件 丰富的快捷键 快捷键 加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl

ysCover 1225

codeforces 538 A.Cutting Banner

A. Cutting Banner time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A large banner with word CODEFORCES was o

ysCover 1132

hdu 5202 Rikka with string(模拟)

Rikka with string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 625    Accepted Submission(s): 244 Problem Description As we know, Ri

ysCover 1058
上一篇: Codeforces Round #249 (Div. 2) B. Pasha Maximizes(模拟)
下一篇: poj 2192 Zipper(DFS+剪枝)
雨狮子
博客等级 码龄12年 24粉丝 185原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址