SDUT 3923
Description
snow 是个热爱打字的家伙,每次敲出更快的速度都会让他很开心。现在,他拿到一篇新的打字文章,已知这篇文章只有 26 个小写英文字母,给出 snow 打出这 26 个英文字母分别需要多少时间 (s),问 snow 打完这篇文章获得的 kpm(打正确的字数/所花的分钟数)最大为多少?
注意 snow 可能会打错一些字哦。打错的必定是文章里面存在的。
Input
多组输入。
对于每组数据,首先输入 26 个整数,分别表示打出 a, b, c, ..., z 这 26 个字母需要的时间(保证是 int 范围内的正整数),然后给出一个字符串,长度不超过 1000,保证只包含小写英文字母。
Output
对于每组数据,输出一行,表示最大的 kpm,保留 2 位小数。
Sample Input
1 2 2 1 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
abcd
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
abcd
Sample Output
40.00
25.71 不知道打错哪些字会使kpm最高....
要么是打错零个,要么是打错一个,要么是打错三个......
如果需要打错字的话,肯定是将耗时多的字打错,会提高kpm,所以从后向前遍历一遍就好了。
还需要注意一点,前缀和数组的应用。
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<deque>
#include<iostream>
using namespace std;
typedef long long LL;
struct cha
{
char c;
int time;
} cha[];
int con[];
char day[];
bool cmp(struct cha a,struct cha b)
{
if(a.time==b.time)
return a.c<b.c;
return a.time<b.time;
}
int main()
{
int i,p,j;
char mid;
double min1,x;
while(scanf("%d",&con['a'])!=EOF)
{
for(i='b'; i<='z'; i++)
scanf("%d",&con[i]);
p=-;
getchar();
gets(day);
for(i=; i<=; i++)
{
if(day[i]==)
break;
else
{
cha[++p].c=day[i];
cha[p].time=con[day[i]];
}
}
sort(cha,cha+p+,cmp); for(i=; i<=p; i++)
cha[i].time+=cha[i-].time; min1=((double)(p+)/cha[p].time)*;
for(i=p-; i>=; i--)
{
x=(double)(i+)/(cha[i].time+(cha[].time*(p-i)))*;
if(x>min1)
min1=x;
}
printf("%.2lf\n",min1);
}
return ; }
SDUT 3923的更多相关文章
- 【叉积】【sdut 2508 图形密码】
图形密码 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 题目链接:http://acm.sdut.edu.cn/sdutoj/p ...
- sdut 1592转置矩阵【稀疏矩阵的压缩存储】【快速转置算法】
转置矩阵 Time Limit: 1000ms Memory limit: 32768K 有疑问?点这里^_^ 题目链接:http://acm.sdut.edu.cn/sdutoj/proble ...
- sdut 2125串结构练习--字符串匹配【两种KMP算法】
串结构练习——字符串匹配 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目链接:http://acm.sdut.edu.cn/sduto ...
- sdut 2498【aoe 网上的关键路径】
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2498 代码超时怎么破: #include< ...
- sdut 487-3279【哈希查找,sscanf ,map】
487-3279 Time Limit: 2000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 题目链接: sdut: http://acm.sdut.ed ...
- sdut 1465 公共因子
公共因子 Time Limit: 1000MS Memory limit: 65536K 题目描述 题目链接:http://acm.sdut.edu.cn/sdutoj/problem.php?act ...
- 排队打饭 sdut 2443【最简单的贪心法应用举例】
排队打饭 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 题目链接:http://acm.sdut.edu.cn/sdutoj/p ...
- sdut 2445 小学数学
小学数学 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 题目链接:http://acm.sdut.edu.cn/sdutoj/p ...
- 最终排名 sdut 2446
最终排名 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 题目链接:http://acm.sdut.edu.cn/sdutoj/p ...
随机推荐
- java复利计算基本代码
源代码: public class Calculate { public static void main(String[] args){ double money = 1000; //本金 int ...
- PAT 甲级 1132 Cut Integer
https://pintia.cn/problem-sets/994805342720868352/problems/994805347145859072 Cutting an integer mea ...
- 小程序解密 encryptedData 获取 unionID 等信息
index.php <?php include_once "wxBizDataCrypt.php"; // $appid 由小程序微信官方后台获取 $appid = 'wx4 ...
- hadoop对于压缩文件的支持
转载:https://www.cnblogs.com/ggjucheng/archive/2012/04/22/2465580.html hadoop对于压缩格式的是透明识别,我们的MapReduce ...
- [微软官网]One Windows Kernel
One Windows Kernel https://techcommunity.microsoft.com/t5/Windows-Kernel-Internals/One-Windows-Kerne ...
- lxs1314 is not in the sudoers file. This incident will be reported.
虚拟机下面 普通用户用sudo执行命令时报"xxx is not in the sudoers file.This incident will be reported"错误,解决 ...
- ES2015中的解构赋值
ES2015中允许按照一定的模式,从数组和对象中提取值,对变量进行赋值,被称为”解构(Destructering)“. 以前,为变量赋值,只能指定值. /** * 以前,为变量赋值,只能直接指定值 * ...
- [二十三]SpringBoot 之 redis
本文章牵涉到的技术点比较多:spring Data JPA.Redis.Spring MVC,Spirng Cache,所以在看这篇文章的时候,需要对以上这些技术点有一定的了解或者也可以先看看这篇文章 ...
- [十六]SpringBoot 之 读取环境变量和绑定属性对象
1.读取环境变量 凡是被spring管理的类,实现接口EnvironmentAware 重写方法 setEnvironment 可以在工程启动时,获取到系统环境变量和application配置文件中的 ...
- 【BZOJ3566】概率充电器(动态规划)
[BZOJ3566]概率充电器(动态规划) 题面 BZOJ Description 著名的电子产品品牌 SHOI 刚刚发布了引领世界潮流的下一代电子产品--概率充电器: "采用全新纳米级加工 ...