| 9 | using namespace std; |
| 10 | |
| 11 | int main() |
| 12 | { |
| 13 | int t; //define the variable that gonna hold the number of test cases |
| 14 | cin>>t; //take input |
| 15 | while(t--){ |
| 16 | int n,k; //define n and k numbers that we gonna work with |
| 17 | long long int sum=0; //the maximum sum we gonna get *notation*:we define it as Long long because it will overflow int |
| 18 | cin>>n>>k; //take inputs |
| 19 | vector <int> v(n); //define vector of numbers of size n |
| 20 | for(int i=0;i<n;i++) cin>>v[i]; //taking input |
| 21 | sort(v.rbegin(),v.rend()); //sortthe vector in descending order |
| 22 | sum=v[0]; |
| 23 | for(int i=1;i<=k;i++) sum+=v[i]; //calculating the maximum difference we could reach to |
| 24 | cout<<sum<<endl; |
| 25 | } |
| 26 | return 0; |
| 27 | } |
| 28 | //Happy Coding :)) |
nothing calls this directly
no outgoing calls
no test coverage detected