题意:

你有一个榨汁机 还有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. ECMAScript6之String类型的扩展

    String类型的扩展 模板字符串 模板字符串是字符串的增强版,既可以当做普通的字符串使用,也可以在字符串中嵌入变量,它用反引号`来表示. //普通字符串 `In javascript '\n' is ...

  2. Bucket Sort - leetcode [桶排序]

    桶排序(Bucket sort)或所谓的箱排序,是一个排序算法,工作的原理是将数组分到有限数量的桶里.每个桶再个别排序(有可能再使用别的排序算法或是以递归方式继续使用桶排序进行排序).桶排序是鸽巢排序 ...

  3. layoutSubviews在什么情况下会被调用

    layoutSubviews在以下情况下会被调用: 1.init初始化不会触发layoutSubviews. 2.addSubview会触发layoutSubviews. 3.设置view的Frame ...

  4. kali客户端攻击

    浏览器攻击 browser_autpwn2 (BAP2) mkdir /test 为接受响应的服务器创建目录   use auxiliary/server/browser_autopwn2  set ...

  5. 单向链表仿LinkedList

    public class ChainTable { private Node firstNode;//第一个节点 private Node lastNode;//最后一个节点 private int ...

  6. 【USACO】草地排水

    Drainage Ditches 草地排水 usaco 4.2.1描述在农夫约翰的农场上,每逢下雨,Bessie最喜欢的三叶草地就积聚了一潭水.这意味着草地被水淹没了,并且小草要继续生长还要花相当长一 ...

  7. eclipse中link方式安装插件

    今天需要给eclipse安装svn插件,觉得link方式便于管理于是就打算用这种方式来安装. 我电脑上的eclipse的安装目录是   E:\tools\eclipse   下面开始安装 1.在ecl ...

  8. IIS7添加mp4 MINE类型报错:无法写入配置文件

    解决方法: 方法一: 可能是由于文件为只读属性,所以修改网站文件访问权限,把此文件夹或者文件的写入权限给了这个用户. 方法二: 可能由于网站目录所在的分区是fat32格式,所以要把网站目录放在NTFS ...

  9. Python基础(七)-文件操作

    一.文件处理流程 1.打开文件,得到文件句柄赋值给一个变量 2.通过句柄对文件进行操作 3.关闭文件 二.基本操作 f = open('zhuoge.txt') #打开文件 first_line = ...

  10. GitHub上优秀的ThirdParty

    仅为个人记录. 1.SwiftyJSON GitHub地址:https://github.com/SwiftyJSON/SwiftyJSON 2.CryptoSwift GitHub地址:https: ...