菜菜菜!!!这么撒比的模拟题,听厂长在一边比比比了半天,自己想一想,然后纯模拟一下,中间过程检测一下,妥妥的就可以过。

题意:有N个东西要去搞碎,每个东西有一个高度,然后有一台机器支持里面可以达到的最大高度,东西可以连续放进去,只要不超过h就行了,每秒可以搞k高度,然后让你算时间

直接code:

#include<cstdio>
#include<vector>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define INF 0X3f3f3f3f
#define N 100010
typedef long long LL; LL a[N];
LL b[N]; bool cmp(LL n,LL m)
{
return n>m;
} int main()
{
LL n,k,h;
cin>>n>>h>>k;
for(int i=0; i<n; i++)
{
scanf("%I64d",&a[i]);
}
LL ans=0;
LL nowh=0;
int i=0; for(int i=0;i<n;i++)
{
if(nowh+a[i]<=h)
{
nowh+=a[i];
}
else
{
ans+=nowh/k;
if(nowh%k)
ans++;
nowh=0;
i--;
}
if(nowh>=k)
{
ans+=nowh/k;
nowh%=k;
}
// printf("nowh=%d\n",nowh);
// printf("ans =%d\n",ans);
}
if(nowh)
{
ans+=nowh/k;
if(nowh)
ans++;
}
printf("%I64d\n",ans);
return 0;
}

Codeforces Round #355 (Div. 2) B. Vanya and Food Processor的更多相关文章

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

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

  3. Codeforces Round #355 (Div. 2) D. Vanya and Treasure 分治暴力

    D. Vanya and Treasure 题目连接: http://www.codeforces.com/contest/677/problem/D Description Vanya is in ...

  4. Codeforces Round #355 (Div. 2) C. Vanya and Label 水题

    C. Vanya and Label 题目连接: http://www.codeforces.com/contest/677/problem/C Description While walking d ...

  5. Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题

    A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...

  6. Codeforces Round #355 (Div. 2) D. Vanya and Treasure dp+分块

    题目链接: http://codeforces.com/contest/677/problem/D 题意: 让你求最短的从start->...->1->...->2->. ...

  7. Codeforces Round #355 (Div. 2) D. Vanya and Treasure

    题目大意: 给你一个n × m 的图,有p种宝箱, 每个点上有一个种类为a[ i ][ j ]的宝箱,a[ i ][ j ] 的宝箱里有 a[ i ][ j ] + 1的钥匙,第一种宝箱是没有锁的, ...

  8. Codeforces Round #355 (Div. 2)C - Vanya and Label

    啊啊啊啊啊啊啊,真的是智障了... 这种题目,没有必要纠结来源.只要知道它的结果的导致直接原因?反正这句话就我听的懂吧... ">>"/"&" ...

  9. 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table

    题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...

随机推荐

  1. c语言-01背包问题

    01背包问题 问题:有N件物品和一个容量为V的背包.第i件物品的费用是c[i],价值是w[i].求解将哪些物品装入背包可使价值总和最大. 分析: 这是最基础的背包问题,特点是:每种物品仅有一件,可以选 ...

  2. mysql 内置函数大全 mysql内置函数大全

    mysql 内置函数大全 2013年01月15日 19:02:03 阅读数:4698 对于针对字符串位置的操作,第一个位置被标记为1. ASCII(str) 返回字符串str的最左面字符的ASCII代 ...

  3. Python 模块的安装与使用

    我们知道使用函数不仅减轻了工作量,而且使代码更加简洁,更加的易于维护.但如果在另一个文件中,我们希望使用上一个文件中定义的某个函数,我们应该怎么办呢?我们需要重新将上一个函数再次实现一遍吗?而且,当我 ...

  4. 多媒体开发之---h264 取流解码分析

    1. nalu_unit_type = *((unsigned char *)pEmptyBuf->bufVirtAddr+4); nalu_unit_type = nalu_unit_type ...

  5. [Selenium]通过Selenium实现在当前浏览器窗口点击一个图标之后,弹出另外一个窗口,关闭这个窗口,再回到原来的窗口进行操作

    public void clickReportIcon(){ String initialWindowHandle = driver.getWindowHandle(); //保存原始的浏览器窗口 p ...

  6. Hadoop集群搭建-虚拟机安装(转)(一)

    1.软件准备 a).操作系统:CentOS-7-x86_64-DVD-1503-01 b).虚拟机:VMware-workstation-full-9.0.2-1031769(英文原版先安装)  VM ...

  7. JSON与localStorage的爱恨情仇

    在使用localStorage时,我们会给一个key存取一个value,这个value可以是一个普通的字符串,也可以是一个对象,如果是一个字符串,我们就需要通过JSON.stringify来转化为JS ...

  8. linux 解决 Device eth0 does not seem to be present

    在虚拟机中安装cent os系统,然后配置网络 执行命令ifconfig 没有看到eth0的信息: 重启网卡报错: service network restart Shutting down loop ...

  9. Vue中 key keep-alive

    keep-alive key <!DOCTYPE html> <html> <head> <title></title> <scrip ...

  10. POJ3281 Dining —— 最大流 + 拆点

    题目链接:https://vjudge.net/problem/POJ-3281 Dining Time Limit: 2000MS   Memory Limit: 65536K Total Subm ...