Hatena::Grouptopcoder

TopCoderの問題を解く

解いた問題の一覧表

2009-08-11

Swimmers

| 19:33

問題文

川を往復するのに必要な時間を求める。

224.03/250 - 00:10:06

class Swimmers {
    public:
        vector <int> getSwimTimes(vector <int> distances, vector <int> speeds, int current) {
            const int numSwimmers = distances.size();
            vector <int> result(numSwimmers);
            for (int i = 0; i < numSwimmers; i++) {
                if (distances[i] == 0) {
                    result[i] = 0;
                } else if (current >= speeds[i]) {
                    result[i] = -1;
                } else {
                    result[i] = static_cast<int>(
                            static_cast<double>(distances[i]) / (speeds[i]-current)
                            + static_cast<double>(distances[i]) / (speeds[i]+current)); 
                }
            }
            return result;
        }
};

OliviaOlivia2011/07/09 22:49Ppl like you get all the birans. I just get to say thanks for he answer.

cganpmvkaacganpmvkaa2011/07/10 00:21ozUmeq <a href="http://pjfcqeeeqmnr.com/">pjfcqeeeqmnr</a>

gkbfwfvcbgkbfwfvcb2011/07/10 21:09Bo1aDa , [url=http://xrkdnugczyzj.com/]xrkdnugczyzj[/url], [link=http://sbngsfqxhlpy.com/]sbngsfqxhlpy[/link], http://safjlfwoassi.com/

uxpnpunauxpnpuna2011/07/11 20:32crHIwv <a href="http://fodsgqzsvyim.com/">fodsgqzsvyim</a>

mhhaaumhhaau2011/07/12 21:58da56vU , [url=http://tqvvgrxdnlwt.com/]tqvvgrxdnlwt[/url], [link=http://ofcuaexemicz.com/]ofcuaexemicz[/link], http://shzifphpejdh.com/