Source ¶
import java.util.Scanner;
public class Running {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int M = sc.nextInt();
int T = sc.nextInt();
int U = sc.nextInt();
int F = sc.nextInt();
int D = sc.nextInt();
int [] path = new int[T];
for(int i=0; i<T; i++){
if(sc.next().equals("f")){
path[i] = F*2;
}else{
path[i] = U+D;
}
}
int run = 0;
for(int i=0; i<T; i++){
run += path[i];
if(run >= M){
System.out.println(i);
break;
}
}
}
}










