#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("avx2")
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define all(m) (m).begin(), (m).end()
#define rall(m) (m).rbegin(), (m).rend()
#define vec vector
#define sz(a) (int) (a).size()
#define mpp make_pair
#define mtt make_tuple
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tui;
template <typename T>
using prq = priority_queue <T>;
template <typename T>
using pgq = priority_queue <T, vec <T>, greater <T>>;
template <typename T> bool umin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> bool umax(T &a, T b) { return a < b ? a = b, 1 : 0; }
inline int solve(){
int n, k;
cin >> n >> k;
vec <pii> a(n);
for (int i = 0; i < n; ++i){
int x, y;
cin >> x >> y;
a[i] = {x + y, x - y};
}
sort(all(a));
vec <ll> res;
auto work = [&](ll d, bool fl){
vec <ll> ans;
set <pll> s;
for (int r = 0, l = 0; r < n; ++r){
while(a[l].fi + d < a[r].fi){
s.erase({a[l].se, a[l].fi}), ++l;
}
auto [x, y] = a[r];
auto it = s.lower_bound({y - d, -3e9});
while(sz(ans) < k){
if (it == s.end()) break;
auto [cy, cx] = *it;
if (x + d < cy) break;
ans.push_back(max(abs(x - cx), abs(y - cy)));
++it;
}
s.insert({a[r].se, a[r].fi});
}
if (fl){
while(sz(ans) < k){
ans.push_back(d + 1);
}
res = ans;
}
return sz(ans) >= k;
};
ll len = 0;
for (int i = 31; ~i; --i){
len += 1LL << i;
if (work(len, 0)){
len -= 1LL << i;
}
}
work(len, 1);
sort(all(res));
for (auto &i: res){
cout << i << "\n";
}
return 0;
}
inline void precalc(){}
signed main(){
// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int tst = 1; //cin >> tst;
precalc();
while(tst--) solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
118 ms |
6844 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
925 ms |
22872 KB |
Output is correct |
2 |
Correct |
925 ms |
22792 KB |
Output is correct |
3 |
Correct |
85 ms |
8716 KB |
Output is correct |
4 |
Correct |
853 ms |
22816 KB |
Output is correct |
5 |
Correct |
945 ms |
24048 KB |
Output is correct |
6 |
Correct |
960 ms |
24144 KB |
Output is correct |
7 |
Correct |
950 ms |
23496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1829 ms |
19512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1829 ms |
19512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
118 ms |
6844 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
118 ms |
6844 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |