5分钟写完 水水更开心

//By SiriusRen
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int m,t,u,f,d;
char jy;
int main(){
scanf("%d%d%d%d%d",&m,&t,&u,&f,&d);
for(int i=1;i<=t;i++){
cin>>jy;
if(jy=='f'){
if(m-2*f>=0)m-=2*f;
else {printf("%d\n",i-1);return 0;}
}
if(jy=='d'||jy=='u'){
if(m-u-d>=0)m=m-u-d;
else {printf("%d\n",i-1);return 0;}
}
}
printf("%d\n",t);
}
05-17 01:10