#include <iostream>
#include <cstdlib>
#include <stdio.h>
using namespace std;
char road[100005];
int road_t[100005];
int main()
{
int M, T;
int U, F, D;
scanf("%d%d%d%d%d", &M, &T, &U, &F, &D);
for(int i = 1; i <= T; ++i)
{
cin >> road[i];
}
for(int i = 1; i <= T; ++i)
{
if(road[i] == 'u') road_t[i] = U+D;
else if(road[i] == 'f') road_t[i] = F*2;
else if(road[i] == 'd') road_t[i] = D+U;
}
int sum = 0;
for(int i = 1; i <= T; ++i)
{
sum += road_t[i];
if(sum > M)
{
cout << i-1 << endl;
break;
}
if(sum == M)
{
cout << i << endl;
break;
}
}
return 0;
}
tyvj p1003- 越野跑
最新推荐文章于 2019-11-30 20:05:07 发布