1561.cpp (266B)
1 class Solution { 2 public: 3 int maxCoins(vector<int> &piles) { 4 sort(piles.begin(), piles.end()); 5 6 int res = 0; 7 for (int i = piles.size() / 3; i < piles.size(); i += 2) { 8 res += piles[i]; 9 } 10 11 return res; 12 } 13 };