# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
946762 | hmm789 | Road Construction (JOI21_road_construction) | C++14 | 1625 ms | 16012 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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});
Compilation message (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... |