U E D R , A S I H C RSS

달리기/강소현

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;
			}
		}
	}
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2011-09-26 06:50:16
Processing time 0.0829 sec