[Codeforces677B]Vanya and Food Processor(模拟,数学)
题目链接:http://codeforces.com/contest/677/problem/B
题意:n个土豆,每个土豆高ai。现在有个加工机,最高能放h,每次能加工k。问需要多少次才能把土豆全加工完。
模拟就行了,加工次数用相除的结果,一个一个来会TLE
/*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define fr first
#define sc second
#define cl clear
#define BUG puts("here!!!")
#define W(a) while(a--)
#define pb(a) push_back(a)
#define Rlf(a) scanf("%lf", &a);
#define Rint(a) scanf("%d", &a)
#define Rll(a) scanf("%I64d", &a)
#define Rs(a) scanf("%s", a)
#define Cin(a) cin >> a
#define FRead() freopen("in", "r", stdin)
#define FWrite() freopen("out", "w", stdout)
#define Rep(i, len) for(int i = 0; i < (len); i++)
#define For(i, a, len) for(int i = (a); i < (len); i++)
#define Cls(a) memset((a), 0, sizeof(a))
#define Clr(a, x) memset((a), (x), sizeof(a))
#define Full(a) memset((a), 0x7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
#define lowbit(x) x & (-x)
#define onenum(x) __builtin_popcount(x)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef map<string, int> msi;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; const int maxn = ;
int n, h, k;
int a[maxn]; int main() {
// FRead();
while(~scanf("%d%d%d",&n,&h,&k)) {
For(i, , n+) Rint(a[i]);
LL ret = ;
int i = ;
LL tmp = ;
while(i <= n) {
while(i <= n && tmp + a[i] <= h) tmp += a[i++];
if(tmp < k) {
ret++;
tmp = ;
}
else {
ret += tmp / k;
tmp %= k;
}
}
if(tmp > ) ret++;
cout << ret << endl;
}
RT ;
}
[Codeforces677B]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 ...
- [ An Ac a Day ^_^ ] CodeForces 677B Vanya and Food Processor 模拟
题意: 你有一个榨汁机 还有n个土豆 榨汁机可以容纳h高的土豆 每秒可以榨k高的东西 问按顺序榨完土豆要多久 思路: 直接模拟 一开始以为是最短时间排了个序 后来发现多余了…… #include< ...
- 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 ...
- poj-3899-The Lucky Numbers 模拟+数学
题目链接: http://poj.org/problem?id=3899 题目意思: 求给定区间内,只含4.7的数的个数以及通过反转后在该区间内的个数和. 解题思路: 模拟+数学. 代码解释的很详细, ...
- 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)-B. Vanya and Food Processor,纯考思路~~
B. Vanya and Food Processor time limit per test 1 second memory limit per test 256 megabytes input s ...
- 暑假练习赛 006 A Vanya and Food Processor(模拟)
Description Vanya smashes potato in a vertical food processor. At each moment of time the height of ...
- Codeforces Round #284 (Div. 2)A B C 模拟 数学
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 洛谷3月月赛div2 题解(模拟+数学+贪心+数学)
由于本人太蒻了,div1的没有参加,胡乱写了写div2的代码就赶过来了. T1 苏联人 题目背景 题目名称是吸引你点进来的. 这是一道正常的题,和苏联没有任何关系. 题目描述 你在打 EE Round ...
随机推荐
- 在后台直接调用sql
表:FmCashStatistics EFContext db = new EFContext(); string strsql = "SELECT org_info_id,customer ...
- MVC学习系列——记一次失败面试后,感想。
在此写博客之际,热烈庆祝母校苏州科技学院,正式改名为苏州科技大学. 一晃眼,从自己投身IT行业已经两年有余,期间经历了结婚.买房等人生大事,非常感谢我的老婆,谢谢她这么爱我,嫁给我这个码农,呵呵... ...
- Linq小技巧
遍历集合ForEach: listAll.Items.Clear(); List<Users> list = DP.UsersDAO.GetInfoList(); list.ForEach ...
- input 标签的监听事件总结
最近在写一个手机端提交表单的项目,里面用了不少input标签,因为项目不太忙,所以,想做的完美点,但是遇到了一些问题,比如:页面中的必填项如果有至少一项为空,提交按钮就是不能提交的状态,所以需要对所有 ...
- C++中的lambda表达式
1.基本形式: [捕获列表](参数列表){函数体}; 其中捕获列表和函数体不能省略但是捕获列表可以为空,也就是说最简单的lambda表达式是: []{}; 2.lambda表达式又叫匿名函数 ...
- PDF.NET框架操作——工具应用(一)
PDF.NET是个开源的项目其解决UI层(WinForm / Web)控件数据绑定.映射与查询: BLL层实体对象查询(OQL):DAL层SQL语句和.NET数据访问代码映射(查看 SQL-MAP ...
- 【POJ】【2125】Destroying the Graph
网络流/二分图最小点权覆盖 果然还是应该先看下胡伯涛的论文…… orz proverbs 题意: N个点M条边的有向图,给出如下两种操作.删除点i的所有出边,代价是Ai.删除点j的所有入边,代价是Bj ...
- hdu 4578 Transformation 线段树
没什么说的裸线段树,注意细节就好了!!! 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> ...
- Android ActionBar与ViewPager合用
内容可以左右滑动,因为使用了ViewPager(我这里用了V4包) view_pager_main.xml <?xml version="1.0" encoding=&quo ...
- lintcode :最长上升连续子序列
题目: 最长上升连续子序列 给定一个整数数组(下标从 0 到 n-1, n 表示整个数组的规模),请找出该数组中的最长上升连续子序列.(最长上升连续子序列可以定义为从右到左或从左到右的序列.) 样例 ...