Advertisement
a53

Cioc_EU

a53
Feb 1st, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. long long a[200000],b[200000],x;
  4.  
  5. int main()
  6. {
  7. ifstream f("cioc.in");
  8. ofstream g("cioc.out");
  9. int c,n,k,i;
  10. f>>c>>n>>k;
  11. for(i=0;i<n;++i)
  12. f>>a[i],b[i]=a[i];
  13. nth_element(b,b+k-1,b+n);
  14. x=b[k-1];
  15. cout<<x;
  16. k=count_if(a,a+n,[&](long long i){ return (i<=x);});
  17. if(c==1)
  18. g<<k;
  19. else
  20. {
  21. c=k;
  22. for(i=n-1;i>=0;--i)
  23. {
  24. if(a[i]<=x)
  25. a[i+c]=2*a[i],--c;
  26. a[i+c]=a[i];
  27. }
  28. for(i=0;i<n+k;++i)
  29. (g<<a[i]).put(' ');
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement