2028.cpp (414B)
1 class Solution { 2 public: 3 vector<int> missingRolls(const vector<int> &rolls, int mean, int n) const { 4 int sum = mean * (n + size(rolls)); 5 int left = sum - accumulate(begin(rolls), end(rolls), 0); 6 7 if (left < n || n * 6 < left) return {}; 8 9 vector<int> res(n, left / n); 10 11 for (int i = 0; i < left % n; i++) { 12 res[i]++; 13 } 14 15 return res; 16 } 17 };