fork(4) download
  1. #include <bits/stdc++.h>
  2. #include <algorithm>
  3. #include <queue>
  4. #define ll long long
  5. #define mp make_pair
  6. #define pb push_back
  7. #define ff first
  8. #define ss second
  9. #define pii pair<int,int>
  10. #define mod 998244353
  11. #define endl '\n'
  12. #define f(i,a,b) for(i=a;i<b;i++)
  13. #define MAX(a,b,c) max(a,max(b,c))
  14. #define MIN(a,b,c) min(a,min(b,c))
  15. #define PI 3.1415926535897932
  16. #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  17. #define input_file freopen("op.txt", "r", stdin);
  18. #define output_file freopen("op1.txt", "w", stdout);
  19. using namespace std;
  20.  
  21. int main(){
  22. fast_io
  23.  
  24. int t = 1;
  25. while(t--){
  26. ll n,k,i,x,s=0;
  27. priority_queue<ll> pq;
  28. cin>>n>>k;
  29. f(i,0,n){
  30. cin>>x;
  31. pq.push(x);
  32. }
  33. while(k--){
  34. x = pq.top();
  35. pq.pop();
  36. x /= 2;
  37. pq.push(x);
  38. }
  39. while(!pq.empty()){
  40. s += pq.top();
  41. pq.pop();
  42. }
  43. cout<<s<<endl;
  44. }
  45. return 0;
  46. }
Time limit exceeded #stdin #stdout 5s 4197464KB
stdin
Standard input is empty
stdout
Standard output is empty