Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- long long a[200000],b[200000],x;
- int main()
- {
- ifstream f("cioc.in");
- ofstream g("cioc.out");
- int c,n,k,i;
- f>>c>>n>>k;
- for(i=0;i<n;++i)
- f>>a[i],b[i]=a[i];
- nth_element(b,b+k-1,b+n);
- x=b[k-1];
- cout<<x;
- k=count_if(a,a+n,[&](long long i){ return (i<=x);});
- if(c==1)
- g<<k;
- else
- {
- c=k;
- for(i=n-1;i>=0;--i)
- {
- if(a[i]<=x)
- a[i+c]=2*a[i],--c;
- a[i+c]=a[i];
- }
- for(i=0;i<n+k;++i)
- (g<<a[i]).put(' ');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement