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> ...
随机推荐
- 跟阿根一起学Java Web开发一:开发环境搭建及JSPGen基础配置
JSPGenSDF软件开发框架(于2014年5月5号公布4.0版).简称JSPGen,专用Java Web方面平台式软件开发,整个框架也能够说是前台与后台的一个粘合剂,如今对JSPGenSDF进行开发 ...
- scss - 语法
1.在一个样式导入另一个样式(@import "example.css") 2.scss单行注释不会显示出来 3.强大的变量(定义后,全局可使用) 4.全局默认变量(加!defau ...
- SAP 锁对象 基本概念与基本操作 SE11
一.SAP为什么要设置锁: 1,保持数据的一致性 假设几个用户要訪问相同的资源,须要找到一种同步訪问的方法去保持数据的一致性.比方说,在航班预订系统中,须要检查还有没有空座位,当检 ...
- 微信小程序项目实例
目前为止最全的微信小程序项目实例 2018年03月20日 11:38:28 Happy王子乐 阅读数:4188 wx-gesture-lock 微信小程序的手势密码 WXCustomSwitch ...
- AIX下RAC搭建 Oracle10G(二)主机配置
AIX下RAC搭建系列 AIX下RAC搭建 Oracle10G(二)主机配置 环境 节点 节点1 节点2 小机型号 IBM P-series 630 IBM P-series 630 主机名 AIX2 ...
- CSDN-markdown编辑器之从线上导入Markdown文件
CSDN-markdown编辑器支持从线上导入Markdown文件的功能,假设你用其他支持Markdown的编辑器在网上写了博客文章或说明档,想公布到CSDN博客中,就能够使用本功能非常方便的完毕 ...
- Django-权限信息初始化
数据库 from django.db import models class Menu(models.Model): """ 菜单组: """ ...
- 如何动态地给vSphere虚拟机模板注入信息
在做vSphere自动化安装过程中,遇到这样一个需求:将vCenter Server做成模板,在给用户自动化装好vSphere后, 下载vCenter Server模板并启动虚拟机,然后将vCente ...
- nyoj 题目10 skiing —— 南阳oj
题目信息例如以下: skiing 时间限制:3000 ms | 内存限制:65535 KB 难度:5 描写叙述 Michael喜欢滑雪百这并不奇怪, 由于滑雪的确非常刺激.但是为了获得速度,滑的区 ...
- 使用Qt发送HTTPS请求
示例代码: #include "mainwindow.h" #include "ui_mainwindow.h" #include <QNetworkAc ...