当前位置: 代码迷 >> 综合 >> SDUT 3923 打字
  详细解决方案

SDUT 3923 打字

热度:39   发布时间:2024-01-19 08:00:12.0

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

 

 

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){for(;;){double a[9999],t[9999];char s[9999];int i,len;if(scanf("%lf",&a[0])==EOF)break;for(i=1;i<26;i++)scanf("%lf",&a[i]);//for(i=0;i<26;i++)//printf("%.1lf ",a[i]);scanf(" %s",s);len=strlen(s);//printf("%d\n",len);for(i=0;i<len;i++){t[i]=a[s[i]-'a'];//printf("%.2lf\n",t[i]);}sort(t,t+len);double sum=0,ans;for(i=0;i<len;i++)sum+=t[i];ans=len*60.0/sum;while(len--){sum-=t[len];sum+=t[0];ans=max(ans,len*60.0/sum);}printf("%.2lf\n",ans);}return 0;
}