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. CF1149A Prefix Sum Primes

    思路: 质数一定是奇数.实现: #include <bits/stdc++.h> using namespace std; int main() { int n, t, x, y; whi ...

  2. HTTP 三次握手  建立连接 和  四次握手断开连接

    三次握手建立连接    第一次握手:主机A发送位码为syn=1,随机产生seq number=1234567的数据包到服务器,主机B由SYN=1知道,A要求建立联机: 第二次握手:主机B收到请求后要确 ...

  3. -bash: mail: command not found

    近日,安装了一个最小化的centos 6.3 6,用mail发送邮件进行测试的时候提示-bash: mail: command not found mailx没有安装,于是: yum -y insta ...

  4. LeetCode Add and Search Word - Data structure design (trie树)

    题意:实现添加单词和查找单词的作用,即实现字典功能. 思路:'.' 可以代表一个任何小写字母,可能是".abc"或者"a.bc"或者"abc.&quo ...

  5. 图片,二进制,oracle数据库

    图片在oracle数据库中一般以二进制存在,存储类型是blob,然而clob类型一般存储的是大于4000的字符,不能用来存储图像这样的二进制内容,下面展示一下实现图像,二进制,oracle 数据库的应 ...

  6. 51nod 算法马拉松17 解题报告 以后不能赛中写题解(查逐梦者抄袭本人代码...

    B题(数学题: 问(1+sqrt(2)) ^n  能否分解成 sqrt(m) +sqrt(m-1)的形式  如果可以 输出 m%1e9+7 否则 输出no n<=1e18 刚看题没思路 暴力一下 ...

  7. HDU 6052 To my boyfriend(容斥+单调栈)

    题意:对于一个n*m的方格,每个格子中都包含一种颜色,求出任意一个矩形包含不同颜色的期望. 思路: 啊啊啊啊啊,补了两天,总算A了这道题了,简直石乐志,前面的容斥还比较好写,后面的那个>13那个 ...

  8. Ubuntu 16.04下Java环境安装与配置

    首先下载linux下的安装包 登陆网址https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.h ...

  9. 一、numpy入门

    Array import numpy as np # create from python list list_1 = [1, 2, 3, 4] array_1 = np.array(list_1)# ...

  10. java HttpServletRequest 重复流读取

    在用reset接口的时候,常常会使用request.getInputStream()方法,但是流只能读取一次,一旦想要加上一个过滤器用来检测用户请求的数据时就会出现异常.   在过滤器中通过流读取出用 ...