Codeforces 677B Vanya and Food Processor【模拟】

AJ-Report开源数据大屏存在远程命令执行漏洞 该平台可以通过post方式在validationRules参数对应值中进行命令执行,可以获得服务器权限,登陆管理后台接管大屏。如果被攻击者利用,危害后果十分严重。 阅读详情

B. Vanya and Food Processor
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Vanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed h and the processor smashes k centimeters of potato each second. If there are less than k centimeters remaining, than during this second processor smashes all the remaining potato.

Vanya has n pieces of potato, the height of the i-th piece is equal to ai. He puts them in the food processor one by one starting from the piece number 1 and finishing with piece number n. Formally, each second the following happens:

  1. If there is at least one piece of potato remaining, Vanya puts them in the processor one by one, until there is not enough space for the next piece.
  2. Processor smashes k centimeters of potato (or just everything that is inside).

Provided the information about the parameter of the food processor and the size of each potato in a row, compute how long will it take for all the potato to become smashed.

Input

The first line of the input contains integers n, h and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ h ≤ 109) — the number of pieces of potato, the height of the food processor and the amount of potato being smashed each second, respectively.

The second line contains n integers ai (1 ≤ ai ≤ h) — the heights of the pieces.

Output

Print a single integer — the number of seconds required to smash all the potatoes following the process described in the problem statement.

Examples
Input
5 6 3
5 4 3 2 1
Output
5
Input
5 6 3
5 5 5 5 5
Output
10
Input
5 6 3
1 2 1 1 1
Output
2
Note

Consider the first sample.

  1. First Vanya puts the piece of potato of height 5 into processor. At the end of the second there is only amount of height 2 remaining inside.
  2. Now Vanya puts the piece of potato of height 4. At the end of the second there is amount of height 3 remaining.
  3. Vanya puts the piece of height 3 inside and again there are only 3 centimeters remaining at the end of this second.
  4. Vanya finally puts the pieces of height 2 and 1 inside. At the end of the second the height of potato in the processor is equal to 3.
  5. During this second processor finally smashes all the remaining potato and the process finishes.

In the second sample, Vanya puts the piece of height 5 inside and waits for 2 seconds while it is completely smashed. Then he repeats the same process for 4 other pieces. The total time is equal to 2·5 = 10 seconds.

In the third sample, Vanya simply puts all the potato inside the processor and waits 2 seconds.


题目大意 :

一共有N个物品需要进行处理,每个物品的高度为ai,对应机器最多可以放置H高度的物品,每秒机器处理掉K高度的物品。

问整个过程最少需要多少秒就能完成。


思路:


1、对应处理好之前机器中剩余的余数量。


2、如果余数+ai>H,那么则先清空机器,再放置ai高度的物品进去,如果ai+余数<=H,那么直接丢进去处理即可。


Ac代码:

#include<stdio.h>
#include<string.h>
using namespace std;
#define ll __int64
int main()
{
    ll n,h,k;
    while(~scanf("%I64d%I64d%I64d",&n,&h,&k))
    {
        ll output=0;
        ll yu=0;
        for(int i=1;i<=n;i++)
        {
            int x;
            scanf("%d",&x);
            if(yu+x>h)
            {
                yu=0;
                output++;
                output+=x/k;
                yu=x%k;
            }
            else
            {
                output+=(x+yu)/k;
                yu=(x+yu)%k;
            }
        }
        if(yu>0)
        output++;
        printf("%I64d\n",output);
    }
}




【报错解决】OpenClaw 报错 ENOENT: no such file or directory, open ‘/root/.npmrc‘:配置文件路径不存在 本文分析了OpenClaw平台在国产操作系统环境下运行时出现的ENOENT: no such file or directory, open '/root/.npmrc'错误。该问题源于容器环境中root用户的npm配置文件缺失,导致插件依赖安装失败。文章详细解释了npm配置加载机制和容器环境的特殊性,提出了四种解决方案:手动创建配置文件、写入基础配置、使用全局配置替代以及容器启动时自动初始化。最后指出该错误暴露了工程中对默认路径盲目信任的问题,强调显式声明运行环境依赖的重要性。 阅读详情

相关推荐

camera——HAL层知识分享

CameraHAL层是Android相机系统的核心中间层,负责连接Framework层与硬件驱动层。它通过标准化接口解耦软硬件,实现跨平台兼容性,同时为厂商提供硬件定制空间。主要功能包括:设备管理、数据流处理、参数控制以及图像优化。关键子系统涵盖预览、拍照、录像、对焦与曝光等模块,采用HAL3的"请求-响应"模型实现精细控制。性能优化重点关注启动时间、帧率稳定性和延迟控制。通过分层架构设计(接口层-核心层-适配层)和缓冲池机制,确保高效数据传输和硬件资源调度。

2302_77429403的博客 2107

Codeforces677B

http://codeforces.com/contest/677/problem/B B. Vanya and Food Processor time limit per test 1 second memory limit per test 256 megabytes input standard input output standard out

Olga_jing的博客 892

树莓派+STM32+激光雷达:大学生工训赛智能物流小车全栈开发实录(附避坑指南)

本文详细记录了基于树莓派、STM32和激光雷达的智能物流小车全栈开发过程。文章从系统架构设计、硬件集成、软件框架搭建到机械臂控制与视觉辅助定位,系统阐述了如何构建一个完整的机器人系统,并分享了在电源管理、通信延迟、里程计误差等关键环节的实战避坑指南,为嵌入式与机器人开发提供了宝贵经验。

kotlin6android的博客 752

Codeforces 677B Vanya and Food Processor (模拟的好题)

B. Vanya and Food Processor time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya smashes potato in a vertic

Pig_Me的博客 885

电力电子技术文章:ACOT控制模式在Buck变换器中的频率稳定性分析

本文深入分析了ACOT控制模式在Buck变换器中实现频率稳定性的原理与优势。通过对比传统COT模式,阐述了ACOT如何通过自适应调整导通时间,将开关频率锁定在设定值,从而有效应对输入电压与负载变化。文章还探讨了其在轻载DCM模式下的高效与平滑切换特性,并提供了关键的设计考量与实战指南。

cc789的博客 1166

强化学习实战:如何用PPO算法训练一个超级马里奥AI(附完整代码)

本文提供了一份详细的强化学习实战指南,教你如何使用PPO算法训练一个能玩《超级马里奥》的AI智能体。内容涵盖从环境搭建、自定义奖励函数设计到PPO智能体的PyTorch完整实现,并附有可运行的代码,帮助开发者快速上手游戏AI开发。

h6j7k8l9p0的博客 955

Codeforces Round #677 (Div. 3)A-G题解

Codeforces Round #677 (Div. 3)A-G题解 比赛链接:https://codeforces.ml/contest/1433/ A题 水,施行 题意为给定一个1到9999的每一位上数字相同的整数x,现在按照一定规则报数,问报到x的时候,总共报了多少位的数字。 报数规则为从1,11,111,1111到2,22,222,2222…到9,99,999,9999。 注意到我们需要关注的只是x是由哪个数字构成的,以及x有几位。 假设x是由若干个y构成的,对于任意的数字比如1,喊完1,11,1

StandNotAlone的博客 1781

请尽可能地详细说明一个VLA项目的立项训练到落地的全流程

一个机器人VLA项目的全流程是一个复杂的系统工程,它深度融合了机器人学 (Robotics)计算机视觉 (CV)和自然语言处理 (NLP)。其核心挑战在于高质量数据的获取和从仿真到现实的有效迁移。与纯粹的软件AI项目相比,它增加了硬件、物理交互和安全性的维度,但其最终能让AI走出虚拟世界、在物理世界中产生实际价值,这也是其巨大的魅力所在。

具身机器人和通用AI 313

CodeForces 677B Vanya and Food Processor

#include<stdio.h> #include<string> #include<cstring> #include<queue> #include<algorithm> #include<functional> #include<vector> #include<iomanip> #include<math.h> #include<iostream> #include<sstream> #i

Katapeltes 425

工程师必收藏,Juniper(Junos)网络设备命令大全

不要直接删除配置 → 使用deactivate配置前先修改大配置用出现风险命令一律用写自动化时一律用格式真正会用 Juniper 的工程师,不是命令多,而是命令用得精。

网络技术联盟站 409

MIKE水动力笔记8_冷启动与热启动

在【MIKE水动力笔记5_建立水动力模型】中,讲到【Step 2 设置模型参数】中的【Initial Conditions】时,提到了冷启动与热启动。本博文就详细讲解何为冷启动、热启动,并通过一个案例具体分析两者不同。...

晏长街的博客 6583

B. Vanya and Food Processor【转】

B. Vanya and Food Processor time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya smashes potato in a vertical ...

weixin_30617737的博客 161

CGAL 网格等高线计算

CGAL 网格等高线计算

dayuhaitang1的博客 462

CodeForces 677B Vanya and Food Processor(打土豆,模拟)

http://codeforces.com/problemset/problem/677/B B. Vanya and Food Processor time limit per test 1 second memory limit per test 256 megabytes input standard input output s

Shyazhut 467

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

贝叶斯统计 [韦来生编]

贝叶斯(Bayes)统计是近几十年来迅速发展起来的数理统计的一个重要分支。贝叶斯方法与经典统计方法的主要不同之处是进行统计推断时除了利用样本信息外,还要利用参数的先验信息,因此可以提高统计推断或统计决策的效果。它在经济、金融、生物、医学、自然科学和社会科学等许多领域具有广泛的应用。贝叶斯方法的研究已渗透到了统计学的几乎所有领域。作者在给中国科学技术大学概率论与数理统计专业本科生开设的“数理统计”课程中有一章专门讲授“贝叶斯方法和统计决策理论”,近十年来也给中国科学技术大学概率统计专业研究生开设过几次“贝叶斯分析”课。本书是在对过去讲稿的内容作了适当的增减和调整的基础上完成的。  本书共分六章。第1章是绪论,介绍了贝叶斯统计的若干基本概念,同时对必要的数理统计的基础知识有重点地作了回顾。第二章介绍了确定先验分布的若干可供选择的方法。第三章介绍了几类常见统计模型参数的后验分布的主要结果和计算方法。第四章和第五章分别介绍了“贝叶斯统计推断”和“贝叶斯统计决策”的内容。第六章介绍了贝叶斯统计计算的若干方法,包括蒙特卡洛方法和马尔可夫链蒙特卡洛(MCMC)方法以及相关统计软件的简介。本书的每一章附右大量的例题和习题,书末附有常用的几个表格和部分习题解答供读者查用。  大约可在54学时内讲授本书的第1章至第六章的主要内容,教师可根据学时需要选讲本书第1章至第六章的部分内容。书中标“*”号的章节可略去不讲,留给读者作为阅读材料。第六章例题中的R代码和部分例题的数据文件等可从作者个人主页下载。  作者在编写本书的过程中参考了J.O.Berger教授的《统计决策论及贝叶斯分析》和茆诗松教授编写的《贝叶斯统计》等书中的一些内容,以及《贝叶斯分析》一书中由张伟平博士编写的有关贝叶斯统计计算的一些内容。在此表示衷心感谢。  本书编写准备过程中,中国科学技术大学统计与金融系的几个研究生帮助完成了本书部分中文的录入和排版,作者对他们的辛勤工作表示真诚的感谢。高等教育出版社为本书的出版给予了大力支持。在此一并致谢。

codeforces 677 B Vanya and Food Processor (模拟)

codeforces #355 B(Div 2)http://http://codeforces.com/contest/677/problem/B B. Vanya and Food Processor time limit per test 1 second memory limit per test 256 megabytes input standard input out

wchhlbt的博客 556

蓝牙模块HM-10手册

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

codeforces 677B Vanya and Food Processor(模拟)

思路:SB模拟... #include using namespace std; const int maxn = 1e5+7; int n; long long h,k,a[maxn]; int main() { scanf("%d%lld%lld",&n,&h,&k); for(int i=1;i<=n;i++) scanf("%d",&a[i]);

围巾的ACM博客 650

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

[Codeforces677B]Vanya and Food Processor(模拟,数学)

题目链接:http://codeforces.com/contest/677/problem/B 题意:n个土豆,每个土豆高ai。现在有个加工机,最高能放h,每次能加工k。问需要多少次才能把土豆全加工完。 模拟就行了,加工次数用相除的结果,一个一个来会TLE 1 /* 2 ━━━━━┒ギリギリ♂ eye! 3 ┓┏┓┏┓┃キリキリ♂ mind! 4 ┛┗┛┗┛┃\○/ ...

weixin_30429201的博客 98

codeforces 677B B. Vanya and Food Processor(模拟)

题目链接: B. Vanya and Food Processor time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya smashes potato in a vertica...

weixin_30258027的博客 100

[ An Ac a Day ^_^ ] CodeForces 677B Vanya and Food Processor 模拟

题意: 你有一个榨汁机 还有n个土豆 榨汁机可以容纳h高的土豆 每秒可以榨k高的东西 问按顺序榨完土豆要多久 思路: 直接模拟 一开始以为是最短时间排了个序 后来发现多余了…… 1 #include<stdio.h> 2 #include<iostream> 3 #include<algorithm> 4 #inclu...

weixin_30394333的博客 122

Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题

B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the ...

weixin_30906671的博客 106

CF Round #355 Div.2

http://codeforces.com/contest/677 B. Vanya and Food Processor 题意:有一个食物加工器,每次能加工不超过h高度的土豆,且每秒加工至多k高度的土豆(每次加工完高度变为0)。有n个高度为ai的土豆,每秒钟,只要加工器里面剩余的土豆高度不超过k,且外面还有剩余的土豆未被加工,就会把外面剩余的土豆放进加工器里。问需要多少秒才能加工完全部土豆?...

weixin_30814223的博客 96

codeforces 677E

题意:给出一个1000*1000的举证,问你任意“十字乘积”的最大值。十字可以是#include using namespace std; #define N 2010 int d[N][N]; double s[8][N][N]; int p[8][N][N]; typedef long long LL; #define MOD 1000000007 //0,1 ,1,1, 1,0, 1

LFLONG的博客 405

Codeforces Round #355 (Div. 2) B. Vanya and Food Processor

菜菜菜!!!这么撒比的模拟题,听厂长在一边比比比了半天,自己想一想,然后纯模拟一下,中间过程检测一下,妥妥的就可以过。 题意:有N个东西要去搞碎,每个东西有一个高度,然后有一台机器支持里面可以达到的最大高度,东西可以连续放进去,只要不超过h就行了,每秒可以搞k高度,然后让你算时间 直接code: #include<cstdio> #include<vec...

weixin_30881367的博客 144

Codeforces Round #677 (Div. 3)(题解)

传送门 题目大意: 有一个电话亭,只能按照1,11,111,1111,2,22,222这种顺序打电话,问要打某个电话需要按键的次数 思路: 要给下一个数打电话必须把之前的数字要按的键全按了。 例如:要给222,打电话要将1,11,111,1111这10个键都按了。 每次加上10*(n-1)+nbit*(nbit - 1) /2; #include<bits/stdc++.h> using namespace std; #define LL long long #define IO ios::

yundan12的博客 218

Codeforces Round #677 (Div. 3)部分题解

A - Boring ApartmentsB - Yet Another BookshelfC - Dominant PiranhaD - Little Girl and Maximum Sum 差分 贪心 前缀和

m0_64524852的博客 297

Codeforces Round #355 (Div. 2) B. Vanya and Food Processor (模拟)

B. Vanya and Food Processortime limit per test 1 second memory limit per test 256 megabytes input standard input output standard outputVanya smashes potato in a vertical food processor. At each

滴水穿石,慢慢积累,总会有成果 483
上一篇: Atcoder ABC053【A、B、C、D】
下一篇: Codeforces 677C Vanya and Label【思维】
mengxiang000000
博客等级 码龄11年 627粉丝 2116原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值