记录编号 385105 评测结果 AAAAAAAAAA
题目名称 [HAOI 2013]跑步训练 最终得分 100
用户昵称 GravatarkZime 是否通过 通过
代码语言 C++ 运行时间 0.006 s
提交时间 2017-03-20 09:29:11 内存使用 0.41 MiB
显示代码纯文本
/*kZime*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#define MAXN
using namespace std;
inline int read() {
	int k = 0, f = 1; char c = getchar();
	for(; !isdigit(c); c = getchar())if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) k = k * 10 + c - '0';
	return k * f;
}

inline char in_char() {
	char c = getchar();
	for(; !isalpha(c); c = getchar());
	return c;
}
 
/*-----------------------------------------------------------------------------*/

int v[3] , m, t, s = 0, step = 0;
char c[100233];

int main() {
#ifndef MYLAB
	freopen("HAOI2013T1.in", "r", stdin);
	freopen("HAOI2013T1.out", "w", stdout);
#else
	freopen("in.txt", "r", stdin);
#endif
	m = read();
	t = read();
	for(int i = 0; i <= 2; i++) {
		v[i] = read();
	}
	
	for(int i = 0; i < t; i++) {
		c[i] = in_char();
	}
	
	while(s <= m && step <= t) {
		if(c[step] != 'f') {
			s += v[0] + v[2];
		}
		else {
			s += v[1] << 1;
		}
		step++;
	}
	
	printf("%d",--step);
	
	return 0;
}