【map&pair】#81 A. Transmigration

A. Transmigration
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes are characterized by different skills.

Unfortunately, the skills that are uncommon for the given character's class are quite difficult to obtain. To avoid this limitation, there is the so-called transmigration.

Transmigration is reincarnation of the character in a new creature. His soul shifts to a new body and retains part of his experience from the previous life.

As a result of transmigration the new character gets all the skills of the old character and the skill levels are reduced according to the k coefficient (if the skill level was equal to x, then after transmigration it becomes equal to [kx], where[y] is the integral part of y). If some skill's levels are strictly less than 100, these skills are forgotten (the character does not have them any more). After that the new character also gains the skills that are specific for his class, but are new to him. The levels of those additional skills are set to 0.

Thus, one can create a character with skills specific for completely different character classes via transmigrations. For example, creating a mage archer or a thief warrior is possible.

You are suggested to solve the following problem: what skills will the character have after transmigration and what will the levels of those skills be?

Input

The first line contains three numbers nm and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and mare integers, and k is a real number with exactly two digits after decimal point (1 ≤ n, m ≤ 200.01 ≤ k ≤ 0.99).

Then follow n lines, each of which describes a character's skill in the form "name exp" — the skill's name and the character's skill level: name is a string and exp is an integer in range from 0 to 9999, inclusive.

Then follow m lines each of which contains names of skills specific for the class, into which the character transmigrates.

All names consist of lowercase Latin letters and their lengths can range from 1 to 20 characters, inclusive. All character's skills have distinct names. Besides the skills specific for the class into which the player transmigrates also have distinct names.

Output

Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.

Sample test(s)
input
5 4 0.75
axe 350
impaler 300
ionize 80
megafire 120
magicboost 220
heal
megafire
shield
magicboost
output
6
axe 262
heal 0
impaler 225
magicboost 165
megafire 0
shield 0


这是一个游戏党出的题,原先你有这么多技能,右边是熟练度或者记忆度之类的东西,然后你学习了一些技能的同时以一个比率对已有技能的记忆能力降低成这个比率的数值(遗忘),以前没学过的技能就是0熟练度,学过的技能如果低于100就被忘掉了,问这次学习之后还剩多少技能以及他们的熟练度。

这里我用了map的数据结构,将string和int绑在一起用map是很棒的哦~

先make_pair(str,int*rate) 然后把整数部分不小于100的pair给push进map中,判断新学技能有没有原先不会的,有的话push进去(int部分是0哦)。

最后把map里的东西都打印出来即可。


Code

#include <map>
#include <cstdio>
#include <string>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
// http://codeforces.com/contest/105
// Transmigration
map<string,int> mp;

int main()
{
	int n,m;
	double rate;
	cin>>n>>m>>rate;
	int rat=(int)(rate*100);
	for(int i=0;i<n;i++)
	{
		string name;
		double p;
		cin>>name>>p;
		int pp=p*rat/100;
		if(pp>=100)	mp.insert(make_pair(name,pp));
	}
	for(int i=0;i<m;i++)
	{
		string name;
		cin>>name;
		if(mp[name]==0)mp.insert(make_pair(name,0));
	}
	cout<<mp.size()<<endl;
	for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
	{
		cout<<it->first<<" "<<it->second<<endl;
	}
	return 0;
} 




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

糖果天王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值