Advertisement
leminhkt

noname23

Mar 10th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define iFOR(i, a, b) for(int i=(a); i<=(b); i++)
  3. #define all(x) (x).begin(), (x).end()
  4. using namespace std;
  5. int n, k, res;
  6. int main(){
  7.     ios_base::sync_with_stdio(0); cin.tie(0);
  8.     cin>>n>>k>>res;
  9.     vector<int> a(--n);
  10.     for(int &i:a){
  11.         cin>>i;
  12.         res+=i;
  13.     }
  14.     sort(all(a));
  15.     iFOR(i, 0, n-k-1) res-=2*a[i];
  16.     cout<<res;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement