[ An Ac a Day ^_^ ] CodeForces 677B Vanya and Food Processor 模拟
题意:
你有一个榨汁机 还有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 模拟的更多相关文章
- 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 ...
- 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 ...
- 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 C. Vanya and Scales
C. Vanya and Scales Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w10 ...
- CodeForces 552C Vanya and Scales
Vanya and Scales Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u S ...
- codeforces 492E. Vanya and Field(exgcd求逆元)
题目链接:codeforces 492e vanya and field 留个扩展gcd求逆元的板子. 设i,j为每颗苹果树的位置,因为gcd(n,dx) = 1,gcd(n,dy) = 1,所以当走 ...
- Codeforces 677E Vanya and Balloons
Vanya and Balloons 枚举中心去更新答案, 数字过大用log去比较, 斜着的旋转一下坐标, 然后我旋出来好多bug.... #include<bits/stdc++.h> ...
- Codeforces 677D - Vanya and Treasure - [DP+优先队列BFS]
题目链接:http://codeforces.com/problemset/problem/677/D 题意: 有 $n \times m$ 的网格,每个网格上有一个棋子,棋子种类为 $t[i][j] ...
随机推荐
- js 数值格式化函数
function ForDight(Dight,How){ ,How))/Math.pow(,How); return Dight; } //ForDight(Dight,How):数值格式化函数; ...
- eclipse中debug快捷方式
eclipse中如何跳转到指定行 :ctrl+L 然后输入行数 F5:跳入方法 F6:向下逐行调试 F7:跳出方法 F8:直接跳转到下一个断点 持续更新
- shrio配置说明
1.引入Shiro的Maven依赖 <!-- Spring 整合Shiro需要的依赖 --> <dependency> <groupId>org.apache.sh ...
- css基础和心得(二)
css中的某些样式是具有继承性的.它允许样式不仅应用于某个特定html标签元素 而且应用于其后代.如: p{color:red;} <p>dsffd<spans>sdfasd ...
- [M]MagicTable转换异常解决方法
ApplicationClass转换为_Application异常 这个问题可能是以前安装过不同版本的Office,没有完全卸载时导致的,可尝试通过以下方法解决: 1. 卸载Office,在 控制面板 ...
- sqlserver判断字符串是否是数字
sql2005有个函数ISNUMERIC(expression)函数:当expression为数字时,返回1,否则返回0.这只是一个菜鸟级的解决办法,大多数情况比较奏效. eg: ') --结果为1 ...
- Scrapy框架使用—quotesbot 项目(学习记录一)
一.Scrapy框架的安装及相关理论知识的学习可以参考:http://www.yiibai.com/scrapy/scrapy_environment.html 二.重点记录我学习使用scrapy框架 ...
- selenium grid的使用与配置
一.selenium grid的组成与作用:由一个集线器hub和多个客户机node组成,如果你的程序需要在不用的浏览器,不同的操作系统上测试,而且比较多的case需要多线程远程执行,那么一个比较好的测 ...
- 使用ajax和urlconnection方式调用webservice服务
<html> <head> <title>使用ajax方式调用webservice服务</title> <script> var xhr = ...
- 本地yum库的搭建
1.建立yum服务器 yum服务器可以使用http或者ftp的方式,我们这里选择使用http的方式进行,需要先进行httpd的安装 # yum install httpd 在本地建立包目录 # mkd ...