이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1000000000000000000
#define MOD 1000000007
int n, k, x, y;
pair<int, int> a[2500000];
vector<int> ans;
int dist(int x, int y) {
    return max(abs(a[x].first-a[y].first), abs(a[x].second-a[y].second));
}
void solve(int d) {
    ans.clear();
    multiset<pair<int, int>> s;
    int idx = 0;
    for(int i = 0; i < n; i++) {
        while(a[i].first - a[idx].first > d) {
            s.erase({a[idx].second, idx});
            idx++;
        }
        auto it = s.lower_bound({a[i].second-d, -1});
        while(it != s.end() && it->first <= a[i].second+d) {
            ans.push_back(dist(i, it->second));
            if(ans.size() >= k) return;
            it++;
        }
        s.insert({a[i].second, i});
    }
}
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> x >> y;
        a[i] = {x+y, x-y};
    }
    sort(a, a+n);
    int l = 0, r = INF, m;
    while(l < r) {
        m = (l+r)/2;
        solve(m);
        if(ans.size() >= k) r = m;
        else l = m+1;
    }
    solve(l-1);
    sort(ans.begin(), ans.end());
    while(ans.size() < k) ans.push_back(l);
    for(int i : ans) cout << i << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
road_construction.cpp: In function 'void solve(long long int)':
road_construction.cpp:27:27: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   27 |             if(ans.size() >= k) return;
      |                ~~~~~~~~~~~^~~~
road_construction.cpp: In function 'int32_t main()':
road_construction.cpp:47:23: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   47 |         if(ans.size() >= k) r = m;
      |            ~~~~~~~~~~~^~~~
road_construction.cpp:52:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   52 |     while(ans.size() < k) ans.push_back(l);
      |           ~~~~~~~~~~~^~~| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |