题意:

你有一个榨汁机 还有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 */

最新文章

  1. 常用.NET库使用总结
  2. 提供在线制作icon的网站
  3. 封装jQuery Validate扩展验证方法
  4. hbm配置文件 generator节点各种解释
  5. 夺命雷公狗---微信开发53----网页授权(oauth2.0)获取用户基本信息接口(3)实现世界留言版
  6. cmd的xcopy命令
  7. bcov进行覆盖率统计
  8. postman-----使用CSV和Json文件实现批量接口测试
  9. BZOJ4025 二分图 线段树分治、带权并查集
  10. jquery第一篇
  11. Python学习笔记_1
  12. python3 文件和流
  13. kafka问题集锦
  14. C#Windows Service程序的创建安装与卸载
  15. webpack4 系列教程(二): 编译 ES6
  16. svn数据库自动备份脚本
  17. Dictionary简洁
  18. 实习医生格蕾第十三季/全集Grey’s Anatomy迅雷下载
  19. 【Servlet】web.xml中url-pattern的用法
  20. 【转】WCF设置拦截器捕捉到request和reply消息

热门文章

  1. NGINX----源码阅读---cycle
  2. 使用pabot并发执行robotframework的testSuite
  3. Spring Security(14)——权限鉴定基础
  4. 安装VMWare WorkStation 10 异常【 Failed to create the requested registry keyKey:Installer Error: 1021】
  5. 解决Mac Linux USB Loader“Couldn&#39;t get security scoped bookmarks”错误
  6. 8、关于viewWithTag
  7. Java常用术语及区别
  8. 动态调用WCF
  9. sql 函数 DATEADD 使用
  10. MyBatis-防止Sql注入以及sql中#{}与${}取参数的区别