Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int cost(const vector<int>& weights) {
- if (weights.empty()) {
- return 0;
- }
- vector<bool> allWeights(10000);
- for (int w : weights) {
- allWeights[w] = true;
- }
- int count = 0;
- int i = 0;
- while (i < allWeights.size()) {
- if (allWeights[i]) {
- ++count;
- i += 5;
- } else {
- ++i;
- }
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement