[ An Ac a Day ^_^ ] CodeForces 677B Vanya and Food Processor 模拟
2024-09-11 00:17:36
题意:
你有一个榨汁机 还有n个土豆
榨汁机可以容纳h高的土豆 每秒可以榨k高的东西
问按顺序榨完土豆要多久
思路:
直接模拟
一开始以为是最短时间排了个序 后来发现多余了……
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
#define M(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
int potato[];
int main(){
int n,h,k;
scanf("%d%d%d",&n,&h,&k);
for(int i=;i<n;i++)
scanf("%d",&potato[i]);
ll ans=,high=;
for(int i=;i<n;i++){
if(high+potato[i]<=h) high+=potato[i]; //能放下就放上去
else{ //放不下就打完了再放
high=potato[i];
ans++;
}
ans+=high/k;
high%=k;
}
if(high) ans++; //最后剩一点还要处理一下
printf("%I64d\n",ans);
return ;
}
/* 5 6 3
5 4 3 2 1 5 6 3
5 5 5 5 5 5 6 3
1 2 1 1 1 */
最新文章
- 常用.NET库使用总结
- 提供在线制作icon的网站
- 封装jQuery Validate扩展验证方法
- hbm配置文件 generator节点各种解释
- 夺命雷公狗---微信开发53----网页授权(oauth2.0)获取用户基本信息接口(3)实现世界留言版
- cmd的xcopy命令
- bcov进行覆盖率统计
- postman-----使用CSV和Json文件实现批量接口测试
- BZOJ4025 二分图 线段树分治、带权并查集
- jquery第一篇
- Python学习笔记_1
- python3 文件和流
- kafka问题集锦
- C#Windows Service程序的创建安装与卸载
- webpack4 系列教程(二): 编译 ES6
- svn数据库自动备份脚本
- Dictionary简洁
- 实习医生格蕾第十三季/全集Grey’s Anatomy迅雷下载
- 【Servlet】web.xml中url-pattern的用法
- 【转】WCF设置拦截器捕捉到request和reply消息
热门文章
- NGINX----源码阅读---cycle
- 使用pabot并发执行robotframework的testSuite
- Spring Security(14)——权限鉴定基础
- 安装VMWare WorkStation 10 异常【 Failed to create the requested registry keyKey:Installer Error: 1021】
- 解决Mac Linux USB Loader“Couldn&#39;t get security scoped bookmarks”错误
- 8、关于viewWithTag
- Java常用术语及区别
- 动态调用WCF
- sql 函数 DATEADD 使用
- MyBatis-防止Sql注入以及sql中#{}与${}取参数的区别