题目大意:给出一些原料和价钱和若干份菜谱,每份菜谱都标明所需的原料和数量,找出所有不超过预算的菜谱。

  没什么好说的,主要是对map的运用。

 #include <cstdio>
#include <string>
#include <map>
#include <iostream>
#include <cctype>
#include <algorithm>
using namespace std;
typedef map<string, int> msi; struct Recipe
{
string name;
int cost;
bool operator < (const Recipe& r) const
{
if (cost != r.cost) return cost < r.cost;
return name < r.name;
}
}recipe[]; int main()
{
#ifdef LOCAL
freopen("in", "r", stdin);
#endif
int T;
cin >> T;
getchar();
msi ingredient;
while (T--)
{
string title;
getline(cin, title);
transform(title.begin(), title.end(), title.begin(), ::toupper);
int m, n, b;
cin >> m >> n >> b;
getchar();
ingredient.clear();
string str;
int x;
for (int i = ; i < m; i++)
{
cin >> str >> x;
getchar();
ingredient[str] = x;
}
for (int i = ; i < n; i++)
{
getline(cin, recipe[i].name);
recipe[i].cost = ;
int k;
cin >> k;
getchar();
for (int j = ; j < k; j++)
{
cin >> str >> x;
getchar();
recipe[i].cost += ingredient[str]*x;
}
}
sort(recipe, recipe+n);
cout << title << endl;
if (recipe[].cost > b)
{
cout << "Too expensive!" << endl << endl;
continue;
}
for (int i = ; i < n; i++)
{
if (recipe[i].cost > b) break;
cout << recipe[i].name << endl;
}
cout << endl;
}
return ;
}

UVa 11308 - Bankrupt Baker的更多相关文章

  1. uva 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

  2. UVA 10564 Paths through the Hourglass[DP 打印]

    UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...

  3. UVA 11404 Palindromic Subsequence[DP LCS 打印]

    UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...

  4. UVA&&POJ离散概率与数学期望入门练习[4]

    POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...

  5. UVA计数方法练习[3]

    UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 ...

  6. UVA数学入门训练Round1[6]

    UVA - 11388 GCD LCM 题意:输入g和l,找到a和b,gcd(a,b)=g,lacm(a,b)=l,a<b且a最小 g不能整除l时无解,否则一定g,l最小 #include &l ...

  7. UVA - 1625 Color Length[序列DP 代价计算技巧]

    UVA - 1625 Color Length   白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束   和模拟赛那道环形DP很想,计算这 ...

  8. UVA - 10375 Choose and divide[唯一分解定理]

    UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

  9. UVA - 11584 Partitioning by Palindromes[序列DP]

    UVA - 11584 Partitioning by Palindromes We say a sequence of char- acters is a palindrome if it is t ...

随机推荐

  1. svn up 提示:Skipped '.'

    >svn up Skipped '.' >svn cleanup '.' is not a working copy directory >svn co https://192.16 ...

  2. 进程waitpid()的用法

    代码分析: /* waitpid.c */ #include <sys/types.h> #include <sys/wait.h> #include <unistd.h ...

  3. Eclipse和PyDev搭建完美Python开发环境 Windows篇

    1,安装Python Python是一个跨平台语言,Python从3.0的版本的语法很多不兼容2版本,官网找到最新的版本并下载:http://www.python.org, 因为之前的一个项目是2版本 ...

  4. 转:WebDriver(Selenium2)模拟鼠标经过事件

    在自动化测试过程中,由于javascript的使用,我们常常需要点击一些鼠标经过显示的菜单等元素,这时需要触发该元素的鼠标经过事件.使用WebDriver有以下两种实现. 1.使用Action pub ...

  5. 同花顺核新下单程序的"界面不操作超时时间"的设定

    "界面不操作超时时间"的设定 同花顺核新下单程序的'界面不操作超时时间'的设定 系统> 系统设置> 界面设置> 界面不操作超时时间(分): 在这个输入框里填上个3 ...

  6. json python api

    摘要:对于python来说,json并不是一种数据类型,可以把它视为函数.json.dumps把字典或列表变成json风格的str类型:json.loads把json风格的str类型变成原来的类型(列 ...

  7. PAT (Advanced Level) 1006. Sign In and Sign Out (25)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  8. Java中的局部内部类

    package Smoke; public class Inner { private int num = 3; class Limian{ public void show(){ //内部类可以访问 ...

  9. js 各种常用js验证

    判断http或者https var http = 'https:' == document.location.protocol ? false : true; js的类型检测方式 /**** js的类 ...

  10. javascript 基础系列(一)

    闭包: function 内部访问外部的variables function f(){ alert(ysr); } 报错了. Certain language constructs block the ...