Greed is Good Time : Space : 12345678910111213141516#include <bits/stdc++.h>using namespace std;int score(const std::vector<int>& dice) { unordered_map<int, int> freq; int res = 0; for(auto d : dice) { if(++freq[d] == 3) { freq[d] = 0; if(d == 1) res += 1000; else res += d * 100; } } res += 100 * freq[1]; res += 50 * freq[5]; return res;}