Codeforces Round #355 (Div. 2) B. Vanya and Food Processor
菜菜菜!!!这么撒比的模拟题,听厂长在一边比比比了半天,自己想一想,然后纯模拟一下,中间过程检测一下,妥妥的就可以过。
题意:有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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #355 (Div. 2) D. Vanya and Treasure dp+分块
题目链接: http://codeforces.com/contest/677/problem/D 题意: 让你求最短的从start->...->1->...->2->. ...
- Codeforces Round #355 (Div. 2) D. Vanya and Treasure
题目大意: 给你一个n × m 的图,有p种宝箱, 每个点上有一个种类为a[ i ][ j ]的宝箱,a[ i ][ j ] 的宝箱里有 a[ i ][ j ] + 1的钥匙,第一种宝箱是没有锁的, ...
- Codeforces Round #355 (Div. 2)C - Vanya and Label
啊啊啊啊啊啊啊,真的是智障了... 这种题目,没有必要纠结来源.只要知道它的结果的导致直接原因?反正这句话就我听的懂吧... ">>"/"&" ...
- 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table
题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...
随机推荐
- People seldom do what they believe in. They do what is convenient, then repent.
People seldom do what they believe in. They do what is convenient, then repent. 人们很少真正实践他们的理想.他们只做比较 ...
- SolidEdge 工程图中如何显示彩色工程图
点击这个按钮,然后更新视图 效果如下图所示,注意如果你的装配图(.dft文件)是单独拷贝出来的,装配图所引用的零件无法追溯到,则无法渲染这些零件,因此无法制作彩色工程图.
- mysql 同样内容的字段合并为一条的方法
从两个表中内联取出的数据,当中category_name字段有同样内容,想将具有同样内容的字段进行合并,将amount字段进行加法运算,变成下表中的内容 url=http%3A%2F%2Fdev.my ...
- html5 式程序员表白
html5 式程序员表白 王海庆 于 星期三, 04/06/2014 - 00:44 提交 今天是个好日子,2014年5月20日,表白的最佳时机,虽说孩子已经四岁.结婚已经五年.可是也不能够偷懒.于是 ...
- 解决最新版的ADT没有NDK选项的问题
最新版的ADT不显示NDK,解决方法有两种,第一种方法在线重装一下 这种方法有一个问题就是,google的东西我们经常不能访问,解决方法可以参考http://blog.csdn.net/shi_wei ...
- windows下安装elasticsearch6.2.4
window 下安装 elasticsearch 一.环境搭建需要的环境 1.jdk环境 2.Elasticsearch 3.git 环境 4.node 安装包 二.进行环境的搭建 1.解压Ela ...
- ftk学习记(combox篇)
[声明:版权全部,欢迎转载,请勿用于商业用途. 联系信箱:feixiaoxing @163.com] 上一篇文章谈到了多窗体,还是依照约定看一下效果是什么样的. 假设大家细心一点.就会发现窗体中的l ...
- Serial attached SCSI
http://en.wikipedia.org/wiki/Serial_attached_SCSI Serial attached SCSI From Wikipedia, the free ency ...
- MeiTuanLocateCity
https://github.com/eltld/MeiTuanLocateCity
- I want a mysqldump –ignore-database option
$ time mysqldump --databases `mysql --skip-column-names -e "SELECT GROUP_CONCAT(schema_name SEP ...