# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
995525 | 2024-06-09T09:08:42 Z | vladilius | Road Construction (JOI21_road_construction) | C++17 | 214 ms | 7504 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second #define ins insert const int inf = 1e9; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; cin>>n>>k; vector<pii> p(n + 1); for (int i = 1; i <= n; i++){ cin>>p[i].ff>>p[i].ss; } sort(p.begin() + 1, p.end()); vector<ll> dist; auto get = [&](ll r){ multiset<pii> st; int j = 1; for (int i = 1; i <= n; i++){ if (dist.size() >= k) break; while (j < i && (p[i].ff - p[j].ff) > r){ st.erase(st.find(p[j])); j++; } auto it = st.lower_bound({-inf, p[i].ss - r}); ll R = p[i].ss + r; while (it != st.end() && (*it).ss <= R && dist.size() < k){ ll d = abs(p[i].ff - (*it).ff) + abs(p[i].ss - (*it).ss); if (d <= r){ dist.pb(d); } it++; } st.insert(p[i]); } }; ll l = 0, r = 4LL * inf; while (l + 1 < r){ ll m = (l + r) / 2; get(m); if (dist.size() < k){ l = m + 1; } else { r = m; } dist.clear(); } get(r); sort(dist.begin(), dist.end()); for (int i = 0; i < k; i++){ cout<<dist[i]<<"\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 98 ms | 5128 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 214 ms | 5616 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 138 ms | 2396 KB | Output is correct |
2 | Correct | 194 ms | 7504 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 138 ms | 2396 KB | Output is correct |
2 | Correct | 194 ms | 7504 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 98 ms | 5128 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 98 ms | 5128 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |