空箱精進日記

精進精進アンド精進

AtCoder ABC 119 B - Digital Gifts (200 点)

結論

やるだけ。

考えていたこと

精度大丈夫かな?とヒヤヒヤしながらサブミットしましたが、大丈夫でした。
今思えば配列で持つ必要ないですね。

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    double x[N];
    string u[N];
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> u[i];
    }
    
    double res;
    for (int i = 0; i < N; ++i) {
        if (u[i] == "JPY") {
            res += x[i];
        } else {
            res += x[i] * 380000;
        }
    }
    
    cout << res << endl;
    return 0;

}