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的整数倍的点上分布着灯笼,而在 ...
随机推荐
- Java的学习路线建议(转)
https://www.cnblogs.com/huaxingtianxia/p/5724093.html
- 【PAT】B1058 选择题(20 分)
这道题的逻辑怪复杂的,写起来蛮费时间的 结构体中要储存的信息多,整体不难,信息量大,容易把人搞蒙 #include<stdio.h> #include<string.h> #i ...
- RD340服务器安装windows2003系统
RD340服务器安装windows2003系统云修网
- 20个最常用的Windows命令行
1. 中断命令执行Ctrl + Z 2. 文件/目录cd 切换目录例:cd // 显示当前目录例:cd .. // 进入父目录 3.创建目录md d:\mp3 // 在C:\建立mp3文件夹md d: ...
- Web自动化
# -*- coding:utf-8 -*- ''' Created on Oct 17, 2018 @author: SaShuangYiBing Comment: ''' from seleniu ...
- DP E - Cheapest Palindrome
Keeping track of all the cows can be a tricky task so Farmer John has installed a system to automate ...
- MongoDB修改与聚合二
1.修改方法 一 语法 里面有三个大的语句:一个是查询条件:一个是修改字段:一个是其他参数(目前就有两个) db.table.update( 条件, 修改字段, 其他参数 ) update db1.t ...
- IOS - 执行时 (经常使用函数)
能够通过NSObject的一些方法获取运行时信息或动态运行一些消息: /*Returns a Boolean value that indicates whether the receiving cl ...
- P1057 传球游戏
题目描述 上体育课的时候,小蛮的老师经常带着同学们一起做游戏.这次,老师带着同学们一起做传球游戏. 游戏规则是这样的: nnn 个同学站成一个圆圈,其中的一个同学手里拿着一个球,当老师吹哨子时开始传球 ...
- Python--Windows下安装虚拟环境
为什么需要虚拟环境 在python开发中,我们可能会遇到一种情况:就是当前的项目依赖的是某一个版本,但是另一个项目依赖的是另一个版本,这样就会造成依赖冲突.在这种情况之下,我们就需要一个工具能够将这两 ...