Poj Solution 3672

http://poj.org/problem?id=3672

//* @author ������<hongxp11@163.com>
import java.util.Scanner;


public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        int M = in.nextInt();
        int T = in.nextInt();
        int U = in.nextInt();
        int F = in.nextInt();
        int D = in.nextInt();
        int num = 0;
        int sum = 0;
        for(int i = 0; i < T; i++)
        {
            String s = in.next();
            if(sum > M)
                break;
            if(s.equals("u") || s.equals("d"))
                sum += U + D;
            else if(s.equals("f"))
                sum += F + F;
            num++;
        }
        System.out.println(num - 1);
    }

}

											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *