Hatena::Grouptopcoder

TopCoderの問題を解く

解いた問題の一覧表

2009-09-02

BettingMoney

| 16:55

問題文, SRM 191

How To Dissect a TopCoder Problem Statement -- Algorithm Tutorialsから。

229.00/250

class BettingMoney {
public:
    int moneyMade(vector <int> amounts, vector <int> centsPerDollar, int finalResult) {
        int result = 0;
        for (int i = 0; i < amounts.size(); i++) {
            if (i == finalResult) result -= amounts[i] * centsPerDollar[i];
            else result += 100 * amounts[i];
        }
        return result;
    }
};