---
# System prepended metadata

title: 2600. K Items With the Maximum Sum
tags: [Leetcode, Easy]

---

# 2600. K Items With the Maximum Sum
###### tags: `Leetcode` `Easy`
Link: https://leetcode.com/problems/k-items-with-the-maximum-sum/description/
## Code
```python=
class Solution:
    def kItemsWithMaximumSum(self, numOnes: int, numZeros: int, numNegOnes: int, k: int) -> int:
        if k<=numOnes or k<=numOnes+numZeros: return min(numOnes, k)
        else: return numOnes+(-1)*(k-numOnes-numZeros)
```