Hatena::Grouptopcoder

TopCoderの問題を解く

解いた問題の一覧表

2009-08-10

StairClimb

| 19:34

問題文

階段登り。

248.03/250

class StairClimb {
    public:
        int stridesTaken(vector <int> flights, int stairsPerStride) {
            int steps = 0;
            const static int TURN_STEPS = 2;
            for (int i = 0; i < flights.size(); i++) {
                steps += TURN_STEPS;
                steps += flights[i] / stairsPerStride;
                if (flights[i]%stairsPerStride != 0) steps++;
            }
            steps -= TURN_STEPS;
            return steps;
        }
};