标签: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