1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Solution {
public:
    int maxIceCream(vector<int>& costs, int coins) {
        sort(costs.begin(), costs.end());
        int cur = 0;
        int cnt = 0;
        for(int i = 0; i < costs.size(); i++){
            if(cur + costs[i] <= coins){
                cur += costs[i];
                cnt++;
            }
            else break;
        }
        return cnt;
    }
};
cs


이게 왜 미디엄?