码迷,mamicode.com
首页 > 其他好文 > 详细

D. Boxes Packing

时间:2018-10-13 20:52:34      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:return   href   box   ace   pack   define   code   bre   namespace   

链接

[http://codeforces.com/contest/1066/problem/D]

sb题

代码

#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

标签:return   href   box   ace   pack   define   code   bre   namespace   

原文地址:https://www.cnblogs.com/mch5201314/p/9784025.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!