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

SRM 600 div 2 T 1

时间:2018-08-30 10:53:50      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:names   bsp   sea   for   std   pac   etl   public   cos   

 
贪心+枚举
#include <bits/stdc++.h>
using namespace std;

 

class TheShuttles {
public:
int getLeastCost( vector <int> cnt, int baseCost, int seatCost );
};
int Maxn1,MAXN1;
int TheShuttles::getLeastCost(vector <int> cnt, int baseCost, int seatCost) {
    for (int i = 0; i < cnt.size(); i ++){
        Maxn1 = max(Maxn1, cnt[i]);
    }
    for (int i = 1; i <= Maxn1; i ++){
        int sum = 0;
        for (int j = 0; j < cnt.size(); j ++){
            sum = ((cnt[j] - 1) / i + 1) + sum;
        }
        if ((i * seatCost + baseCost) * sum < MAXN1)
            MAXN1 = (i * seatCost + baseCost) * sum;
    }
    return MAXN1;
}

SRM 600 div 2 T 1

标签:names   bsp   sea   for   std   pac   etl   public   cos   

原文地址:https://www.cnblogs.com/wjnclln/p/9558018.html

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