Submit | All submissions | Best solutions | Back to list |
EI2122Q1M1 - Sum of K distinct Largest |
Given n integers, find the sum of at most k largest distinct values.
Input
- The first line contains two integers n, k (1 ≤ n, m ≤ 105).
- The second line contains n integers (-109 ≤ ai ≤ 109).
Output
The required sum.
Sample
Input |
Output |
10 3 9 5 21 15 16 1 5 1 9 21 |
52 |
10 8 9 5 21 15 16 1 5 1 9 21 |
103 |
Added by: | Ha Minh Ngoc |
Date: | 2021-11-14 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |