您的位置:首页 > 其它

code Gym 100500D T-shirts(暴力)

2015-07-27 18:07 295 查看
因为只能买一次,暴力枚举一下买的衣服的大小。

#include<cstdio>
#include<map>
#include<algorithm>

using namespace std;
typedef long long ll;
#define fi first
#define se second
const int maxn = 1e5+5;
map<int,int> S;

int main()
{
int T;
scanf("%d",&T);
for(int k = 1; k <= T; k++){
int N,D,C;
scanf("%d%d%d",&N,&D,&C);

printf("Case %d: ",k);
if(D<=C) {
int nn = N;
while(nn--) { int t; scanf("%d",&t); }
printf("%lld\n",(ll)D*N);
continue;
}
S.clear();
for(int i = 0; i < N; i++){
int t;
scanf("%d",&t);
S[t]++;
}
int sum = 0;
ll min_cos = (ll)D*N;
for(map<int,int>::iterator it = S.begin(); it != S.end(); it++) {
sum += it->se;
min_cos = min(((ll)C*it->fi-D)*sum+(ll)D*N,min_cos);
}
printf("%lld\n",min_cos);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: