#include <bits/stdc++.h> // pA
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define debug(x) cerr << #x << " = " << (x) << ' '
#define endl cerr << '\n'
#define all(v) (v).begin(), (v).end()
#define lowbit(x) (x)&-(x)
#define pb emplace_back
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const int N = 3e5+5;
const int INF = 2e9;
ll n, Q;
pll p[N];
vector<ll> v;
inline bool chk(ll w)
{
ll i, cnt = 0, L=1;
for (i=1; i <= n; ++i)
{
while (p[i].F-p[L].F > w) ++L;
cnt += i - L;
}
return cnt >= Q;
}
int main(void)
{ IO
ll i, lb, mid, ub, j;
cin >> n >> Q;
for (i=1; i <= n; ++i) cin >> p[i].F >> p[i].S;
sort(p+1, p+n+1);
lb = 1, ub = 1e18;
while (lb < ub)
{
mid = (lb+ub)>>1;
if (chk(mid)) ub = mid;
else lb = mid+1;
}
for (i=1; i <= n; ++i)
{
for (j=i-1; j >= 1; --j)
{
if (p[i].F-p[j].F > lb) break;
v.pb(p[i].F-p[j].F);
}
}
sort(all(v));
for (ll x : v) cout << x << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
36 ms |
4812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
145 ms |
10928 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
110 ms |
4476 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
110 ms |
4476 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
36 ms |
4812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
36 ms |
4812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |