链接

[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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. CF1066D Boxes Packing

    传送门 这题为什么要用二分呢?/huaji 首先可以\(O(n)\)预处理出从某个物品\(i\)开始放,只放一个盒子,能放的最后物品的位置\(j\),只要用两个指针维护左右端点,每次移动一下左端点同时 ...

  6. CF1066D Boxes Packing(二分答案)

    题意描述: 你有$n$个物品,每个物品大小为$a_i$,$m$个盒子,每个盒子的容积为$k$.$Maksim$先生想把物品装入盒子中.对于每个物品,如果能被放入当前的盒子中,则放入当前盒子,否则换一个 ...

  7. 903C. Boxes Packing#俄罗斯套娃问题(map使用)

    题目出处:http://codeforces.com/problemset/problem/903/C 题目大意:求这组数据中数据出现的最大重复次数 #include<iostream> ...

  8. Codeforces Round #515 (Div. 3)

    Codeforces Round #515 (Div. 3) #include<bits/stdc++.h> #include<iostream> #include<cs ...

  9. Codeforces Round #515 (Div. 3) 解题报告(A~E)

    题目链接:http://codeforces.com/contest/1066 1066 A. Vova and Train 题意:Vova想坐火车从1点到L点,在路上v的整数倍的点上分布着灯笼,而在 ...

随机推荐

  1. nodejs中async使用

    waterfall , parallel ,  series  ,  eachSeries //var async = require('async'); /*** *① * 串行有关联 执行每个函数 ...

  2. 转:// 再说 Oracle RAC services

    应用程序工作负载在Oracle 10g中可以被定为services,也称之为服务,能够在单实例中使用,也能够在RAC中单独使用和管理.因此整个数据库负载能够被分割为多个不同的services,通过管理 ...

  3. Linux 性能分析工具汇总合集

    出于对Linux操作系统的兴趣,以及对底层知识的强烈欲望,因此整理了这篇文章.本文也可以作为检验基础知识的指标,另外文章涵盖了一个系统的方方面面.如果没有完善的计算机系统知识,网络知识和操作系统知识, ...

  4. centos7安装python3和pip3

    python3安装 1.安装准备 # 创建安装目录 mkdir /usr/local/python3 #下载python3 wget --no-check-certificate https://ww ...

  5. nargin与varargin的用法

    nargin是用来判断输入变量个数的函数,这样就可以针对不同的情况执行不同的功能.通常可以用它来设定一些默认值.如下例所示: 函数文件 examp.m function fout=examp(a,b, ...

  6. MATLAB——BP神经网络

    1.使用误差反向传播(error back propagation )的网络就叫BP神经网络 2.BP网络的特点: 1)网络由多层构成,层与层之间全连接,同一层之间的神经元无连接 . 2)BP网络的传 ...

  7. 新的WireGuard快照发布

    导读 WireGuard首席开发人员Jason Donenfeld宣布发布WireGuard 0.0.20190123,作为Linux系统和其他平台的安全VPN隧道实施的最新快照. WireGuard ...

  8. PAT A1109 Group Photo (25 分)——排序

    Formation is very important when taking a group photo. Given the rules of forming K rows with N peop ...

  9. flask 路由和视图

    路由设置的俩种方式 @app.route('/xxx') def index(): return 'index' ------------------------------------------ ...

  10. WebSphere下配置HTTP压缩

    WebSphere下配置HTTP压缩 背景 WebSphere本身的安装配置中并不包含HTTP压缩的模块,而是通过新增WebServer来实现的,WebSphere通过Plugin与WebServer ...