Warning: session_start(): open(/tmp/sess_b38d98b1cf56eddff700feab5da875a8, O_RDWR) failed: No space left on device (28) in /data/wiki/inc/init.php on line 239
Warning: session_start(): Failed to read session data: files (path: ) in /data/wiki/inc/init.php on line 239
Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/auth.php on line 430
Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/Action/Export.php on line 103
Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/Action/Export.php on line 103
Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/Action/Export.php on line 103
#include
#include
#include
#include
#include
#define pb push_back
using namespace std;
typedef long long LL;
const int N=2e5+5;
const LL INF=1e18;
vectorpos,neg;
int main()
{
int n;
LL k;
scanf("%d%lld",&n,&k);
for(int i=1;i<=n;i++)
{
int a;
scanf("%d",&a);
if(a>0)pos.pb(a);
else if(a<0)neg.pb(a);
}
sort(pos.begin(),pos.end());
sort(neg.begin(),neg.end());
LL ne=1LL*neg.size()*pos.size();
LL po=1LL*pos.size()*(pos.size()-1)/2+1LL*neg.size()*(neg.size()-1)/2;
LL ze=1LL*n*(n-1)/2-ne-po;
if(k<=ne)
{
LL l=-INF,r=0,ans;
while(l<=r)
{
LL mid=(l+r)/2,num=0;
for(int i=0;imid);
num+=x;
}
for(int i=0;imid);
num+=neg.size()-x;
}
assert(num%2==0);
num=num/2+ze+ne;
if(num