题意:

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

[ An Ac a Day ^_^ ] CodeForces 677B Vanya and Food Processor 模拟的更多相关文章

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

    题目链接: B. Vanya and Food Processor time limit per test 1 second memory limit per test 256 megabytes i ...

  2. 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 ...

  3. Codeforces Round #355 (Div. 2)-B. Vanya and Food Processor,纯考思路~~

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

  4. B. Vanya and Food Processor【转】

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

  5. codeforces C. Vanya and Scales

    C. Vanya and Scales Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w10 ...

  6. CodeForces 552C Vanya and Scales

    Vanya and Scales Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u S ...

  7. codeforces 492E. Vanya and Field(exgcd求逆元)

    题目链接:codeforces 492e vanya and field 留个扩展gcd求逆元的板子. 设i,j为每颗苹果树的位置,因为gcd(n,dx) = 1,gcd(n,dy) = 1,所以当走 ...

  8. Codeforces 677E Vanya and Balloons

    Vanya and Balloons 枚举中心去更新答案, 数字过大用log去比较, 斜着的旋转一下坐标, 然后我旋出来好多bug.... #include<bits/stdc++.h> ...

  9. Codeforces 677D - Vanya and Treasure - [DP+优先队列BFS]

    题目链接:http://codeforces.com/problemset/problem/677/D 题意: 有 $n \times m$ 的网格,每个网格上有一个棋子,棋子种类为 $t[i][j] ...

随机推荐

  1. intellij idea 生成UUID

    Intellij IDEA 默认没启用这个功能 需要手动设置一下 , 下面是路径 Setting->Inspections->Serialization issues->Serial ...

  2. 在vmware workstation10上安装ubuntu14.04,出现以下问题

    VMware提示:已将该虚拟机配置为使用 64 位客户机操作系统.但是,无法执行 64 位操作. (1)设置bois 对于HP电脑来说,刚开机时,按住F10,会出现以下界面: 然后回车进行设置: 重启 ...

  3. AngularJS中如何对Controller与Service进行分层设计与编码

    初学者的Controller 在我们当接触NG后,如需要通过访问远程的API获取一系列的数据进行显示,通常我的Controller代码会写成下面的样子: angular.module('demo') ...

  4. java-进程

    一个java进程,只有一个入口,就是main方法. tomcat是一个java进程,tomcat只有一个入口,org.apache.catalina.startup.Bootstrap  类的main ...

  5. 《Intel汇编第5版》 条件汇编伪指令

    一.条件汇编伪指令和宏使用可以使汇编程序更加灵活 二.通过伪指令来检查函数的参数是否为空,如果为空则输出警告信息 INCLUDE Irvine32.inc includelib Irvine32.li ...

  6. TDD(测试驱动开发)的推广方法论

  7. 简单封装常用js方法

    1.uploadfiy插件封装 /* 参数:uploadID:上传控件ID url:请求后台url路径   callback:回调函数 */ uploadfiy({ uploadID: $('#btn ...

  8. ubuntu 10.4非法关机后上不了网

    用的好好的ubuntu 10.4,非法关机后居然上不了网,右上角的网络图标也不见了,还以为是网卡问题,进入xp,发现一切正常,心里不断地诅咒ubuntu,该死的ubuntu,我windows还天天非法 ...

  9. ThreadLocal 与 static 变量

    ThreadLocal是为解决多线程程序的并发问题而提出的,可以称之为线程局部变量.与一般的变量的区别在于,生命周期是在线程范围内的.static变量是的生命周期与类的使用周期相同,即只要类存在,那么 ...

  10. Docker 安装及问题处理

    1 确定Linux版本 uname -r 2  升级系统(添加 APT 镜像源,添加使用 HTTPS 传输的软件包以及 CA 证书.) sudo apt-get update sudo apt-get ...