Every year, an elephant qualifies to the Arab Collegiate Programming Competition. He graduated this year, but that’s irrelephant. What’s important is that the location of the competition might not have been the same every year. Therefore, after every trip, he always has leftover money in the currency of the country he visited.

Now he wants to see how much Jordanian Dinars he has after all those competitions. Can you help him convert the leftover money from all competitions to Jordanian Dinar, if that makes any cents?

Input

The first line of input is T – the number of test cases.

The first line of each test case contains C and N (1 ≤ C, N ≤ 100000), the number of currency types and the number of competitions, respectively.

The next C lines each contain the name of the currency Ci of maximum length 10 in lowercase and/or uppercase letters, and the value Vi of that currency in Jordanian Dinar (0 < Vi ≤ 1000). The names are case-sensitive.

The next N lines each contains an amount left over from each competition (0 ≤ Ni ≤ 1000), and the name of the currency of that amount (it is guaranteed that the name was either given in the input or is “JD”).

Output

For each test case, print on a single line the total amount of money he has in Jordanian Dinar(JD) rounded to 6 decimal digits.

Example

Input
1
3 5
dollar 0.71
euro 0.76
turkish 0.17
5.1 dollar
6 dollar
7 turkish
3 euro
1.1 JD

Output
12.451000

cin会超时

#include <iostream>
#include <map>
#include <cstdio>
#include <cstring>
using namespace std;int main()
{int t;scanf("%d",&t);while(t--){map <string,double> p;char data[15];double a;int n,m;cin>>n>>m;for(int i=1; i<=n; i++){string k;scanf("%s %lf",data,&a);for(int i=0;i<strlen(data);i++)k=k+data[i];p[k]=a;}p["JD"]=1;double ans=0.0;for(int i=1; i<=m; i++){string k;scanf("%lf %s",&a,data);for(int i=0;i<strlen(data);i++)k=k+data[i];ans+=(p.find(k)->second)*a;}printf("%.6lf\n",ans);}return 0;
}

Make Cents? Gym - 101350M (水)相关推荐

  1. python和pycharm要安装在同一个路径下吗_无法在pyCharm中导入与Anaconda一起安装的文件:需要将Anaconda添加到Python路径吗?...

    我是Python的新手,我想使用AI-Gym运行一些Python的强化学习算法: https://github.com/openai/gym 我想使用tensorflow,所以我用Anaconda制作 ...

  2. Codeforces gym 100685 C. Cinderella 水题

    C. Cinderella Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/ ...

  3. Codeforces Gym 100286I iSharp 水题

    Problem I. iSharp Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest ...

  4. 【CF gym 103260】40th Petrozavodsk Programming Camp, Day 5,2021.2.3 水题2题

    M.Discrete Logarithm is a Joke 题意: 思路: 不难想到an=g^{an+1},因为样例给了 a[1000000]的值,所以反着推就行了. 记得开int128,longl ...

  5. Mirrored String I Gym - 101350H (水)判断回文

    https://vjudge.net/contest/159763#problem/H 判断是不是由指定字符组成的回文串 // // main.cpp // 160929 // // Created ...

  6. GYM 101653 T.Runes(水~)

    Description 给出一个式子,其中有一种数字全部被打了问号,问是否可以填入这个数字使得等式成立且式子合法,所谓合法指的是没有前置0,也不能有-0 Input 第一行一整数T表示用例组数,之后输 ...

  7. GYM 100827 A.Runes(水~)

    Description 给出一个式子,其中有一种数字全部被打了问号,问是否可以填入这个数字使得等式成立且式子合法,所谓合法指的是没有前置0,也不能有-0 Input 第一行一整数T表示用例组数,之后输 ...

  8. Gym - 102388G Snails(水题)

    题意:每天向前进a米,向后退b米,求多少天能到达n米. 题记:按照题目模拟即可. #include<bits/stdc++.h>using namespace std; const int ...

  9. GYM 101086 A.My Friend of Misery(水~)

    Description 给出一些交易记录,+表示交易成功,-表示交易失败,每次交易手续费25元,如果总金额低于交易额加手续费则交易失败,问初始时的钱数有多少种可能 Input 第一行一整数T表示用例组 ...

  10. Gym 环境汇总 (无mojoco版)

    把gym.make 里面的参数改掉,可以得到很多其他的游戏 使用以下方式得到有的环境名称 from gym import envs print(envs.registry.all()) 'Acrobo ...

最新文章

  1. php 插件怎么做的,php 扩展模块如何安装
  2. c# websocketServer base64乱码
  3. 作为本科大学生比较适合的水准比较好的,嵌入式软件系统的会议
  4. 云计算开发教程:Python自动化运维开发实战流程控制
  5. think in java 读书笔记 2 —— 套接字
  6. brew update失败提示:/System/Library/Frameworks/Ruby.framework/。。。解决方法
  7. 虚拟DOM - React的骨干
  8. linux 一键网克,MaxDOS 8.0
  9. VMWare虚拟机启动失败,显示intel VT-X处于禁用状态
  10. py读取xlsx文件
  11. 如何保存微信视频号的视频到本地?
  12. ubuntu vim的 保存退出方法
  13. 【计算机图形学】【OpenGL】基于窗口的Liang-Barsky的折线段裁剪的实现
  14. springboot中service中注入dao失败测试类中注入成功_聊一聊 Java 服务端中的乱象
  15. 野狐围棋QQ怎么显示服务器忙,腾讯野狐围棋
  16. vue中如何使用和风天气插件
  17. Teradata和Exadata
  18. 周博通 | 阿里语音AI入选MIT“全球十大突破技术”;阿里云率先达成国家绿色数据中心标准;iOS协程开发框架coobjc开源...
  19. 今日小程序推荐:熊猫签证-足不出户办签证
  20. C语言实现简单的字符串拼接

热门文章

  1. Apache-Flink深度解析-JOIN-LATERAL-Time Interval(Time-windowed)
  2. 圣诞节马上到了。H5+CSS3+JS制作圣诞帽头像源码送给你们。。。
  3. 《新浪微博平台架构》---阅读
  4. 基于二维码的室内定位技术(二)——实现
  5. 解决spacedesk卸载/重装软件时显示 指定的账户已存在
  6. 爸爸是个计算机工程师,作文:我的爸爸是工程师
  7. 美化 PowerShell
  8. HTML Typo.css 中文网页重设与排版
  9. 亚马逊EC2服务器链接方式
  10. APP Bomb Lab