| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 946762 | hmm789 | Road Construction (JOI21_road_construction) | C++14 | 1625 ms | 16012 KiB |
이 제출은 이전 버전의 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) 메시지
| # | 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... | ||||
