• Codeforces Round #355 (Div. 2) B. Vanya and Food Processor


    菜菜菜!!!这么撒比的模拟题,听厂长在一边比比比了半天,自己想一想,然后纯模拟一下,中间过程检测一下,妥妥的就可以过。

    题意:有N个东西要去搞碎,每个东西有一个高度,然后有一台机器支持里面可以达到的最大高度,东西可以连续放进去,只要不超过h就行了,每秒可以搞k高度,然后让你算时间

    直接code:

    #include<cstdio>
    #include<vector>
    #include<string.h>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    #define INF 0X3f3f3f3f
    #define N 100010
    typedef long long LL;
    
    LL a[N];
    LL b[N];
    
    bool cmp(LL n,LL m)
    {
        return n>m;
    }
    
    int main()
    {
        LL n,k,h;
        cin>>n>>h>>k;
        for(int i=0; i<n; i++)
        {
            scanf("%I64d",&a[i]);
        }
        LL ans=0;
        LL nowh=0;
        int i=0;
    
        for(int i=0;i<n;i++)
        {
            if(nowh+a[i]<=h)
            {
                nowh+=a[i];
            }
            else
            {
                ans+=nowh/k;
                if(nowh%k)
                    ans++;
                nowh=0;
                i--;
            }
            if(nowh>=k)
            {
                ans+=nowh/k;
                nowh%=k;
            }
           // printf("nowh=%d
    ",nowh);
           // printf("ans =%d
    ",ans);
        }
        if(nowh)
        {
            ans+=nowh/k;
            if(nowh)
                ans++;
        }
        printf("%I64d
    ",ans);
        return 0;
    }
  • 相关阅读:
    mysql的sql性能分析器
    Maven(一)
    SVN使用(二)
    SVN使用(一)
    php smarty section使用
    php smarty foreach循环注意
    PHP unlink() 函数
    PHP file_exists() 函数
    PHP realpath() 函数
    PHP dirname() 函数
  • 原文地址:https://www.cnblogs.com/keyboarder-zsq/p/5934506.html
Copyright © 2020-2023  润新知