Hay Points
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 5735   Accepted: 3695

Description

Each employee of a bureaucracy has a job description - a few paragraphs that describe the responsibilities of the job. The employee's job description, combined with other factors, such as seniority, is used to determine his or her salary. 
The Hay Point system frees the Human Resources department from having to make an intelligent judgement as to the value of the employee; the job description is merely scanned for words and phrases that indicate responsibility. In particular, job descriptions that indicate control over a large budget or management over a large number of people yield high Hay Point scores.

You are to implement a simplified Hay Point system. You will be given a Hay Point dictionary and a number of job descriptions. For each job description you are to compute the salary associated with the job, according to the system.

Input

The first line of input contains 2 positive integers: m <= 1000, the number of words in the Hay Point dictionary, and n <= 100, the number of job descriptions. m lines follow; each contains a word (a string of up to 16 lower-case letters) and a dollar value (a integer number between 0 and 1,000,000). Following the dictionary are the n job descriptions. Each job description consists of one or more lines of text; for your convenience the text has been converted to lower case and has no characters other than letters, numbers, and spaces. Each job description is terminated by a line containing a period.

Output

For each job description, output the corresponding salary computed as the sum of the Hay Point values for all words that appear in the description. Words that do not appear in the dictionary have a value of 0.

Sample Input

7 2
administer 100000
spending 200000
manage 50000
responsibility 25000
expertise 100
skill 50
money 75000
the incumbent will administer the spending of kindergarden milk money
and exercise responsibility for making change he or she will share
responsibility for the task of managing the money with the assistant
whose skill and expertise shall ensure the successful spending exercise
.
this individual must have the skill to perform a heart transplant and
expertise in rocket science
.

Sample Output

700150
150
#include <stdio.h>
#include <iostream>
#include <map>
#include <string>
#include <cstring>
using namespace std; int main()
{
map<string, int> item;
int m, n, val;
string temp;
cin>>m>>n;
int ans = ;
for (int i = ; i < m; i++)
{
cin>>temp>>val;
item.insert(make_pair<string, int>(temp, val));
}
for (int i = ; i < n; i++)
{
ans = ;
while(cin>>temp)
{
if (temp[] == '.')
{
cout<<ans<<endl;
break;
}
else
{
ans += item[temp];
}
}
}
return ;
}

POJ 2403 Hay Points的更多相关文章

  1. Poj 2403 Hay Points(Map)

    一.题目大意 实现一个工资计算系统.工资的计算规则是:首先,给定一些关键字和对应的价值,这个相对于字典.然后给出的是求职者的描述,如果这个描述中包含关键字则加上对应的价值,总得价值就是这个求职者的工资 ...

  2. Hay Points

    Hay Points TimeLimit: 1 Second   MemoryLimit: 32 Megabyte Totalsubmit: 1022   Accepted: 602 Descript ...

  3. poj 2403

    http://poj.org/problem?id=2403 题意:就是给你m个单词,以及n段对话.每一个单词都有所对应的价值.求对话中的价值总和 题解:很简单,就是用单词和价值对应起来,然后再寻找就 ...

  4. POJ 3805 Separate Points (判断凸包相交)

    题目链接:POJ 3805 Problem Description Numbers of black and white points are placed on a plane. Let's ima ...

  5. POJ 2464 Brownie Points II (树状数组,难题)

    题意:在平面直角坐标系中给你N个点,stan和ollie玩一个游戏,首先stan在竖直方向上画一条直线,该直线必须要过其中的某个点,然后ollie在水平方向上画一条直线,该直线的要求是要经过一个sta ...

  6. [POJ 3788] Interior Points of Lattice Polygons

    同swustoj 169 Interior Points of Lattice Polygons Time Limit: 1000MS   Memory Limit: 65536K Total Sub ...

  7. Problem 1008 Hay Points

    Problem Description Each employee of a bureaucracy has a job description - a few paragraphs that des ...

  8. POJ - 2464 Brownie Points II 【树状数组 + 离散化】【好题】

    题目链接 http://poj.org/problem?id=2464 题意 在一个二维坐标系上 给出一些点 Stan 先画一条过一点的水平线 Odd 再画一条 过Stan那条水平线上的任一点的垂直线 ...

  9. hdu 1156 && poj 2464 Brownie Points II (BIT)

    2464 -- Brownie Points II Problem - 1156 hdu分类线段树的题.题意是,给出一堆点的位置,stan和ollie玩游戏,stan通过其中一个点画垂线,ollie通 ...

随机推荐

  1. Json的详细用法

    参考博客:https://www.cnblogs.com/haiyan123/p/7829080.html 1.json(Javascript  Obiect  Notation,JS对象标记)是一种 ...

  2. mac下相关操作命令

    查看端口使用情况 lsof -i tcp:

  3. 一个制作Xcode5插件的模板

    原Github地址:https://github.com/kattrali/Xcode5-Plugin-Template 安装将 本工成复制到~/Library/Developer/Xcode/Tem ...

  4. 为什么JS是单线程?JS中的Event Loop(事件循环)?JS如何实现异步?setimeout?

    https://segmentfault.com/a/1190000012806637 https://www.jianshu.com/p/93d756db8c81 首先,请牢记2点: (1) JS是 ...

  5. 前端性能优化:细说JavaScript的加载与执行

    本文主要是从性能优化的角度来探讨JavaScript在加载与执行过程中的优化思路与实践方法,既是细说,文中在涉及原理性的地方,不免会多说几句,还望各位读者保持耐心,仔细理解,请相信,您的耐心付出一定会 ...

  6. Jordan 标准型的推论

    将学习到什么 从 Jordan 标准型出发,能够获得非常有用的信息.   Jordan 矩阵的构造 Jordan 矩阵 \begin{align} J=\begin{bmatrix} J_{n_1}( ...

  7. Hopfield 网络(上)

    讲的什么 这部分主要对 Hopfield 网络作一大概的介绍.写了其模型结构.能量函数和网络的动作方式.主要参考了网上搜到的一些相关 PPT.   概述 早在 1982 年,Hopfield 发表的文 ...

  8. 五. web开发基础

    一.HTML 二.CSS 三.JavaScript 四.web框架 1.web框架本质 众所周知,对于所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端 ...

  9. Xcode 6 创建 Objective-C category

    1. Command + N 2. 选择 iOS - Source - Objective-C File 3.File Type 选择 Category,Class 填基于的类名,File填扩展的名

  10. 关于HTML设置访问密码。

    如果你要设置访问密码恐怕要使用sublime_text了 废话不多,开始!!! 先把这些东西加上: <html> <script> 然后开始写代码: 先辨别密码登录正确的情况: ...