HDU 1070 - Select the cheapest product
来源:互联网 发布:java接口与安卓对接 编辑:程序博客网 时间:2024/05/28 18:42
Select the cheapest product
-->>use <vector> to record what we got dynamically.
-->>sort by provide a customized method.
http://acm.hdu.edu.cn/showproblem.php?pid=1070
#include <iostream>#include <string>#include <algorithm>#include <vector>using namespace std;struct Milk {char name[110];int pay;int vol;double price;};bool cmp(const Milk &a, const Milk &b) {if(a.price != b.price)return a.price < b.price;elsereturn a.vol > b.vol; // choose the smaller}int main(){int T;cin >> T;while(T --) {int N;vector <Milk> vec;Milk temp;cin >> N;for(int i = 0; i < N; ++ i) {cin >> temp.name >> temp.pay >> temp.vol;int d = 0;int t = temp.vol;while(t >= 200 && d <= 4) {d ++;t -= 200;}if(d) { // if this milk corresponds to what the problem requests, note it downtemp.price = temp.pay / d; // calculate the price.vec.push_back(temp);}}sort(vec.begin(), vec.end(), cmp);cout << vec[0].name << endl;}return 0;}
0 0
- HDU 1070 - Select the cheapest product
- please select the product flavors
- android studio 发布app出错:please select the product flavors to build and sign
- android studio 发布app出错:please select the product flavors to build and sign
- HDU 5525 Product
- HDU 5525 Product
- hdu-5524 Product
- HDU 5525 Product(数论)
- HDU 5525 Product
- where can i buy the cheapest runescape gold?
- hdu 1678(Shopaholic )(最大折扣)(水题,cheapest)
- Learning Scrum - The Product Backlog
- Product Management for the Web
- Articles from the inner product
- The Codec Engine product package
- Ensure the quality of product
- codeforces817b Makes And The Product
- hdu 5525 Product(数论)
- 同步定制 Unity团队 程序的C#文件模板
- 分析Linux内核创建一个新进程的过程
- 玩转Android---2D图形及动画---Gif动画
- 玩转Android---2D图形及动画---图片处理
- raw_input() 与 input() __ Python
- HDU 1070 - Select the cheapest product
- 玩转Android---2D图形及动画---动画分析(Tween详细分析)
- Python 多线程 multithread
- #111 (div.2) A. Twins
- Leetcode NO.19 Remove Nth Node From End of List
- 黑马程序员--java--多态和内部类
- hdu 多校
- SEL数据类型的简单知识点——和方法有关
- 实现简单HTTP服务器-图片与CGI