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;
}

转载于:https://www.cnblogs.com/mch5201314/p/9784025.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
static int npu_detect_callback_body(unsigned char *pBuffer, int size, int ch_idx, Awnn_Context_t *context) { unsigned char *body_input_buf[2] = {NULL, NULL}; aialgo_context_t *pctx = get_aicontext(); int ret = 0; body_input_buf[0] = pBuffer; body_input_buf[1] = pBuffer + size * 2 / 3; awnn_set_input_buffers(context, body_input_buf); long start_time = get_time_in_us(); awnn_run(context); if (1 == pctx->ai_det_runtime_print || 3 == pctx->ai_det_runtime_print) { alogd("body awnn_run cost %dms", (get_time_in_us() - start_time) / 1000); } Awnn_Post_t post; post.type = (AWNN_DET_POST_TYPE)pctx->attr.ch_info[ch_idx].nbg_type; post.width = pctx->attr.ch_info[ch_idx].src_width; post.height = pctx->attr.ch_info[ch_idx].src_height; post.thresh = pctx->attr.ch_info[ch_idx].thresh; Awnn_Result_t result; awnn_det_post(context, &post, &result); if (result.valid_cnt > 0) { if (pctx->attr.ch_info[ch_idx].draw_orl_enable) { paint_object_detect_region_body(&result, ch_idx); } for (int j = 0; j < result.valid_cnt; j++) { if (1 == pctx->ai_det_result_print || 5 == pctx->ai_det_result_print) { alogd("ch_idx=%d, [%d/%d] cls %d, prob %f, rect[%d,%d,%d,%d]", ch_idx, j + 1, result.valid_cnt, result.boxes[j].label, result.boxes[j].score, result.boxes[j].xmin, result.boxes[j].ymin, result.boxes[j].xmax, result.boxes[j].ymax); } else if (2 == pctx->ai_det_result_print || 6 == pctx->ai_det_result_print) { if (0 == result.boxes[j].label) { alogd("ch_idx=%d, [%d/%d] cls %d, prob %f, rect[%d,%d,%d,%d]", ch_idx, j + 1, result.valid_cnt, result.boxes[j].label, result.boxes[j].score, result.boxes[j].xmin, result.boxes[j].ymin, result.boxes[j].xmax, result.boxes[j].ymax); } } } ret = result.valid_cnt; } return ret; }
最新发布
07-14

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值