D. Boxes Packing
链接
[http://codeforces.com/contest/1066/problem/D]
题意
题目大意 n个物品m个篮子每个篮子容量为k 每个物品重量为a[i] 问能装多少物品 这个人是强迫症 如果没把所有物品装完则把第一个物品
也就是最左边的那个直接从右边枚举就行了
代码
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[200010];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll i,j,k,n,m;
cin>>n>>m>>k;
for(i=1;i<=n;i++) cin>>a[i];
ll ans=0,sum=0,cnt=0;
for(i=n;i>=1;i--){
if(sum+a[i]<=k) sum+=a[i];
else cnt++,sum=a[i];
if(cnt==m) break;
ans++;
}
cout<<ans<<endl;
return 0;
}
D. Boxes Packing的更多相关文章
- Educational Codeforces Round 34 (Rated for Div. 2) C. Boxes Packing
C. Boxes Packing time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Educational Codeforces Round 34 C. Boxes Packing【模拟/STL-map/俄罗斯套娃】
C. Boxes Packing time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Boxes Packing
Boxes Packing Mishka has got n empty boxes. For every i (1 ≤ i ≤ n), i-th box is a cube with side le ...
- CodeForces Round #515 Div.3 D. Boxes Packing
http://codeforces.com/contest/1066/problem/D Maksim has nn objects and mm boxes, each box has size e ...
- CF1066D Boxes Packing
传送门 这题为什么要用二分呢?/huaji 首先可以\(O(n)\)预处理出从某个物品\(i\)开始放,只放一个盒子,能放的最后物品的位置\(j\),只要用两个指针维护左右端点,每次移动一下左端点同时 ...
- CF1066D Boxes Packing(二分答案)
题意描述: 你有$n$个物品,每个物品大小为$a_i$,$m$个盒子,每个盒子的容积为$k$.$Maksim$先生想把物品装入盒子中.对于每个物品,如果能被放入当前的盒子中,则放入当前盒子,否则换一个 ...
- 903C. Boxes Packing#俄罗斯套娃问题(map使用)
题目出处:http://codeforces.com/problemset/problem/903/C 题目大意:求这组数据中数据出现的最大重复次数 #include<iostream> ...
- Codeforces Round #515 (Div. 3)
Codeforces Round #515 (Div. 3) #include<bits/stdc++.h> #include<iostream> #include<cs ...
- Codeforces Round #515 (Div. 3) 解题报告(A~E)
题目链接:http://codeforces.com/contest/1066 1066 A. Vova and Train 题意:Vova想坐火车从1点到L点,在路上v的整数倍的点上分布着灯笼,而在 ...
随机推荐
- k-vim安装及The ycmd server SHUT DOWN (restart with ':YcmRestartServer')这种错误的解决方法
vim配置 下载地址:https://github.com/wklken/k-vim 安装步骤: 1. clone 到本地 git clone https://github.com/wklken/k- ...
- Win10 + MASM32 + EditPlus 汇编语言编程环境设置
下载安装MASM32汇编环境 官方下载站:MASM32 环境变量配置 配置MasmHome变量,值为masm32的安装目录: 配置include和lib变量 include : %MasmHome%\ ...
- VM虚拟机打不开,没有反应,解决方法。
最近的项目开发,需要用到虚拟机,但是打开虚拟机VM8却发现,以前创建的虚拟机都用不了,点击左侧[我的计算机]中的虚拟机列表,没有任何反应,也没有任何错误提示,服务中所有的虚拟机服务都开启了,网上百度没 ...
- strong vs copy
一.前言 在这里,我通过实例去介绍strong和copy的区别(%p打印出来对象的地址) ViewController.h #import <UIKi ...
- Javascript中的undefined、null、""、0值和false的区别总结
在程序语言中定义的各种各样的数据类型中,我们都会为其定义一个"空值"或"假值",比如对象类型的空值null,.NET Framework中数据库字段的空值DBN ...
- windows下安装ElasticSearch的Head插件
es5以上版本安装head需要安装node和grunt(之前的直接用plugin命令即可安装) (一)从地址:https://nodejs.org/en/download/ 下载相应系统的msi,双击 ...
- blinker语音控制Arduino/esp8266开关灯-滑动条使用-文本框交互
总链接: https://www.arduino.cn/thread-78393-1-1.html 语音控制:https://doc.blinker.app/?file=005-App%E4%BD% ...
- 对Promise的理解?
ES6原生提供了promise对象 所谓Promise,就是一个对象,用来传递异步操作的消息.它代表了某个未来才会知道结果的事件(通过是一个异步操作),并且这个事件提供统一的API,可供进一步处理 P ...
- metamask源码学习-metamask-controller.js
The MetaMask Controller——The central metamask controller. Aggregates other controllers and exports a ...
- day14 Python集合的补充
python_1 = ['charon','pluto','ran','charon'] linux_1 = ['ran','xuexue','ting'] p_s = set(python_1) l ...