Problem:
Score : 200 points

Problem Statement

Takahashi received otoshidama (New Year's money gifts) from N of his relatives.

You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC, and x_i and u_i represent the content of the otoshidama from the i-th relative.

For example, if x_1 = 10000 and u_1 = JPY, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = 0.10000000 and u_2 = BTC, the otoshidama from the second relative is 0.1 bitcoins.

If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?

Constraints

2 \leq N \leq 10

u_i = JPY or BTC.

If u_i = JPY, x_i is an integer such that 1 \leq x_i \leq 10^8.

If u_i = BTC, x_i is a decimal with 8 decimal digits, such that 0.00000001 \leq x_i \leq 100.00000000.

Input

Input is given from Standard Input in the following format:

N
x_1 u_1
x_2 u_2
:
x_N u_N

Output

If the gifts are worth Y yen in total, print the value Y (not necessarily an integer).

Output will be judged correct when the absolute or relative error from the judge's output is at most 10^{-5}.

Sample Input 1

2
10000 JPY
0.10000000 BTC

Sample Output 1

48000.0

The otoshidama from the first relative is 10000 yen. The otoshidama from the second relative is 0.1 bitcoins, which is worth 38000.0 yen if converted at the rate of 380000.0 JPY per 1.0 BTC. The sum of these is 48000.0 yen.

Outputs such as 48000 and 48000.1 will also be judged correct.

Sample Input 2

3
100000000 JPY
100.00000000 BTC
0.00000001 BTC

Sample Output 2

138000000.0038

In this case, outputs such as 138001000 and 1.38e8 will also be judged correct.

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)


import java.io.PrintWriter;
import java.util.*;

/**
 * Hello AtCoder.
 *
 * @author kaito0228
 */
public class Main {
  public static void main(String[] args) {
    try (PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in)) {
      solve(sc, out);
      out.flush();

    } catch (Exception e) {
      // DO NOT USE
      e.printStackTrace();
    }
  }

  private static void solve(Scanner sc, PrintWriter out) {
    // TODO
    int n = nint(sc);
    double ans = 0;

    for (int i = 0; i < n; i++) {
      double a = ndouble(sc);
      if (nstr(sc).equals("JPY")) {
        ans += a;
      } else {
        ans += a * 380000;
      }
    }

    out.println(ans);
  }

  // method
  /**
   * Returns an int. int値を受け取り、返します。
   *
   * @param sc Scanner
   * @return int
   */
  private static int nint(Scanner sc) {
    return Integer.parseInt(sc.next());
  }

  /**
   * Returns a long. long値を受け取り、返します。
   *
   * @param sc Scanner
   * @return long
   */
  private static long nlong(Scanner sc) {
    return Long.parseLong(sc.next());
  }

  /**
   * Returns a double. double値を受け取り、返します。
   *
   * @param sc Scanner
   * @return double
   */
  private static double ndouble(Scanner sc) {
    return Double.parseDouble(sc.next());
  }

  /**
   * Returns a String. 文字列を受け取り、返します。
   *
   * @param sc Scanner
   * @return String
   */
  private static String nstr(Scanner sc) {
    return sc.next();
  }

  /**
   * Returns a int array. int値を受け取り、配列にして返します。
   *
   * @param sc Scanner
   * @param length Array length
   * @return int array
   */
  private static int[] intLine(Scanner sc, int length) {
    int[] iLine = new int[length];
    for (int i = 0; i < length; i++) {
      iLine[i] = nint(sc);
    }
    return iLine;
  }

  /**
   * Returns a long array. long値を受け取り、配列にして返します。
   *
   * @param sc Scanner
   * @param length Array length
   * @return long array
   */
  private static long[] longLine(Scanner sc, int length) {
    long[] lLine = new long[length];
    for (int i = 0; i < length; i++) {
      lLine[i] = nlong(sc);
    }
    return lLine;
  }

  /**
   * Returns a String array. 文字列を受け取り、配列にして返します。
   *
   * @param sc Scanner
   * @param length Array length
   * @return String array
   */
  private static String[] strLine(Scanner sc, int length) {
    String[] strLine = new String[length];
    for (int i = 0; i < length; i++) {
      strLine[i] = nstr(sc);
    }
    return strLine;
  }

  /**
   * Returns the maximum value in the list. リスト内で最大値を返します。
   *
   * @param longList List
   * @return long maximum value
   */
  private static long maxFromList(List<Long> longList) {
    return longList.stream().max(Comparator.naturalOrder()).get();
  }

  /**
   * Returns the minimum value in the list. リスト内で最小値を返します。
   *
   * @param longList List
   * @return long minimum value
   */
  private static long minFromList(List<Long> longList) {
    return longList.stream().min(Comparator.naturalOrder()).get();
  }

  /**
   * Returns the sum of each digit. 各桁の和を返します。
   *
   * @param n int
   * @return sum of each digit
   */
  private static int sumDigits(int n) {
    int sum = 0;
    while (n != 0) {
      sum += n % 10;
      n /= 10;
    }
    return sum;
  }

  /**
   * Returns the sum of each digit. 各桁の和を返します。
   *
   * @param n long
   * @return sum of each digit
   */
  private static long sumDigits(long n) {
    long sum = 0;
    while (n != 0) {
      sum += n % 10;
      n /= 10;
    }
    return sum;
  }

  /**
   * Return a list of Integer. Integerのリストを返します。
   *
   * @param sc Scanner
   * @param size list size
   * @return list
   */
  private static List<Integer> getIntegerList(Scanner sc, int size) {
    List<Integer> list = new ArrayList<>();
    for (int i = 0; i < size; i++) {
      list.add(nint(sc));
    }
    return list;
  }

  /**
   * Return a list of Long. Longのリストを返します。
   *
   * @param sc Scanner
   * @param size list size
   * @return list
   */
  private static List<Long> getLongList(Scanner sc, int size) {
    List<Long> list = new ArrayList<>();
    for (int i = 0; i < size; i++) {
      list.add(nlong(sc));
    }
    return list;
  }

  /**
   * Returns the summation of list. リストの要素の合計値を返します。
   *
   * @param list List<Integer>
   * @return sum of list
   */
  private static int sumList(List<Integer> list) {
    int sum = 0;
    for (Integer n : list) {
      sum += n;
    }
    return sum;
  }

  /**
   * Returns the average of list. リストの要素の平均値を返します。
   *
   * @param list List<Integer>
   * @return average of list
   */
  private static double aveList(List<Integer> list) {
    return (double) sumList(list) / list.size();
  }

  /**
   * Returns the greatest common divisor of the two given values. 与えた2つの値の最大公約数を返します。
   *
   * @param m long
   * @param n long
   * @return greatest common divisor
   */
  private static long gcd(long m, long n) {
    if (m < n) return gcd(n, m);
    if (n == 0) return m;
    return gcd(n, m % n);
  }

  /**
   * Returns the least common multiple of the two given values. 与えた2つの値の最小公倍数を返します。
   *
   * @param m long
   * @param n long
   * @return least common multiple
   */
  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
  }

  /**
   * Returns the most frequent value in the list. リスト内で最頻出数値を返します。
   *
   * @param list List
   * @return most frequent value
   */
  private static Integer mode(List<Integer> list) {
    switch (list.size()) {
      case 0:
        throw new IllegalArgumentException();
      case 1:
        return list.get(0);
      default:
        Integer[] x = new Integer[list.size()];
        list.toArray(x);
        Arrays.sort(x);

        int maxValue = 1,
            maxKey = x[x.length - 1],
            previousKey = x[x.length - 1],
            breakPoint = x.length - 1;
        for (int i = x.length - 2; i >= 0; --i) {
          if (previousKey != x[i]) {
            if (maxValue < breakPoint - i) {
              maxValue = breakPoint - i;
              maxKey = x[i + 1];
            }
            previousKey = x[i];
            breakPoint = i;
          }
        }
        return breakPoint + 1 > maxValue ? x[0] : maxKey;
    }
  }

  private static Map<Integer, Integer> primeFactorize(long num) {
    Map<Integer, Integer> map = new HashMap<>();
    int i = 2;
    while (i * i <= num) {
      while (num % i == 0) {
        num /= i;
        if (map.containsKey(i)) {
          int tmp = map.get(i);
          tmp++;
          map.put(i, tmp);
        } else {
          map.put(i, 1);
        }
      }
      i++;
    }
    if (num > 1) map.put((int) num, 1);
    return map;
  }

  /**
   * Returns "YES" or "NO". アッパーケースのYES,NOを返します。
   *
   * @param bool boolean
   * @return "YES" or "NO"
   */
  private static String upperYESNO(boolean bool) {
    return bool ? "YES" : "NO";
  }

  /**
   * Returns "Yes" or "No". パスカルケースのYes,Noを返します。
   *
   * @param bool boolean
   * @return "Yes" or "No"
   */
  private static String pascalYesNo(boolean bool) {
    return bool ? "Yes" : "No";
  }
}