[ 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] ...
随机推荐
- Thinkphp5 设置日志
database.php 'debug' => false, application/config.php 'log' => [ // 日志记录方式,支持 file socket 'typ ...
- PHP学习资源
PHPerNote PHPerNote 是一个php程序员的工作生活笔记,本站包含了php网络编程学习教程,数据库(主要是MySQL数据库)教程,javascript,jquery,div+css,h ...
- mysql 时间
显示当前时间: mysql> select now(); +---------------------+ | now() | +---------------------+ | -- :: | ...
- Error(10028)
两个进程里都有同一个条件判断的话,会产生并行信号冲突的问题. 同一个信号不允许在多个进程中赋值,否则则为多驱动. 进程的并行性决定了多进程不同能对同一个对象进行赋值.
- CentOS7 citus9.5 集群安装及管理
1 所有节点配置 #------服务安装 服务yum update -y #------扩展依赖安装yum install -y epel-release && yum update ...
- winform开线程,避免页面假死
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- 安装PHP
'./configure' '--prefix=/usr/local/php5.6.21' '--with-config-file-path=/usr/local/php5.6.21/etc' '-- ...
- Anaconda 安装概要
Anaconda 作为开源项目,集成了Python的大部分第三方包,如:pandas,Numpy,scipy等. 1. 下载地址:https://www.continuum.io/downloads ...
- 阿里云-对象储存OSS
最近 需要搞一个阿里云的文件上传 手机端主要做了图片上传 pod安装:pod 'AliyunOSSiOS', '~> 2.5.2' 主要就是需要四个参数:accessKey secretKey ...
- LWP::UserAgent介绍2
#这个LWP::UserAgent一般要配合其他模块使用 #比如: #HTTP::Request #HTTP::Cookie #HTTP::Respose #HTTP::Status #LWP::Us ...