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; }
相关文章推荐
- .NET学习笔记 -- 那堆名词到底是啥(CLR、CLI、CTS、CLS、IL、JIT)
- 注入式开发
- oracle 任务使用
- JavaScript中的Repaint和Reflow用法详解
- breeze densematrix 基本操作
- apache worker性能调优
- Codeforces 557E - Ann and Half-Palindrome (字典树+DP)
- 短信拦截再总结
- 使用Spring Boot和Gradle创建AngularJS项目
- HDU 3271-SNIBB(数位dp)
- HDU1052——田忌赛马(贪心)
- 欢迎使用CSDN-markdown编辑器
- 【C语言】3子棋游戏,
- NYOJ 找数达人 (找n个数构成m是否存在)
- 怎样将整型变量转换为字符变量 然后串口 或者LCD发送出来(STM32) 以及sprintf的用法
- Android视频播放开源库vitamio
- Xcode 快捷键
- Spark1.4.1 编译与安装
- 如何成功实施SDL提供的官方Android平台Demo
- 通知