#include #include // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define DEBUG(x) cout << #x << ": " << x << endl #define INFILE() freopen("input.txt", "r", stdin) #define REP(i, a, b) for (int i = (a); i < (b); i++) #define REPC(i, a) REP(i, 0, a) #define RREP(i, a, b) for (int i = (a); i >= (b); i--) #define RREPC(i, a) RREP(i, a, 0) #define ALL(s) begin(s), end(s) #define RALL(s) rbegin(s), rend(s) using namespace std; using ll = long long; using ull = unsigned long long; using i_i = pair; using ll_i = pair; using i_ll = pair; using d_i = pair; using ll_ll = pair; using d_d = pair; static constexpr ll LL_MOD = 1000000009; static constexpr int I_MOD = 1000000007; static constexpr double EPS = numeric_limits::epsilon(); static constexpr double PI = 3.14159265358979323846264338327950288; static map scanType = { { typeid(int), "%d" }, { typeid(ll), "%lld" }, { typeid(double), "%lf" }, { typeid(char), "%c" } }; template static void scan(vector &v); static void scan(vector &v, bool isWord = true); // static boost::dynamic_bitset<> scan(char trueValue = 'o'); int main(int argc, char *argv[]) { // INFILE(); vector labels(5); vector coins(5); REPC(i, 5) { cin >> labels[i] >> coins[i]; } vector> slot(3); REPC(i, 3) { int count = 0; cin >> count; slot[i] = vector(count); scan(slot[i]); } double expected = 0; vector counts(5); REPC(i, 5) { string label = labels[i]; int get_coin = coins[i]; double prob = 1; int total = 1; for (const auto& reel : slot) { double label_count = count(ALL(reel), label); prob *= label_count / size(reel); total *= static_cast(label_count); } expected += get_coin * prob ; counts[i] = total * 5; } cout << expected * 5 << endl; for (const auto& n : counts) { cout << n << endl; } return 0; } template static void scan(vector &v) { auto tFormat = scanType[typeid(T)]; for (T &n : v) { scanf(tFormat, &n); } } static void scan(vector &v, bool isWord) { if (isWord) { for (auto &n : v) { cin >> n; } return; } int i = 0, size = v.size(); string s; getline(cin, s); if (s.size() != 0) { i++; v[0] = s; } for (; i < size; ++i) { getline(cin, v[i]); } } //static boost::dynamic_bitset<> scan(char trueValue) { // string s; // getline(cin, s); // // if (s.size() == 0) { // getline(cin, s); // } // // for_each(begin(s), end(s), // [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; }); // return boost::dynamic_bitset<>(string(rbegin(s), rend(s))); //}