# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
557415 | 2022-05-05T10:13:29 Z | 600Mihnea | Road Construction (JOI21_road_construction) | C++17 | 10000 ms | 9292 KB |
#include <bits/stdc++.h> bool home = 1; using namespace std; typedef long long ll; const int N=250000+7; struct T{ ll x; ll y; }; int n; int k; T a[N]; ll how_many_under(ll d) { ll sol=0; for (int i=1;i<=n;i++) { for (int j=i+1;j<=n;j++) { ll dij=abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y); if(dij<=d){ sol++; } } } return sol; } signed main() { #ifdef ONLINE_JUDGE home = 0; #endif home=0; if (home) { freopen("I_am_iron_man", "r", stdin); } else { ios::sync_with_stdio(0); cin.tie(0); } cin>>n>>k; for (int i=1;i<=n;i++) cin>>a[i].x>>a[i].y; ll low=0,high=(ll)1e10,sol=-1; while (low<=high) { ll mid=(low+high)/2; if(how_many_under(mid)<=k) { sol=mid; low=mid+1; }else{ high=mid-1; } } vector<ll> v; for (int i=1;i<=n;i++) { for(int j=i+1;j<=n;j++) { ll dij=abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y); if(dij<=sol){ v.push_back(dij); } } } sort(v.begin(),v.end()); assert((int)v.size()<=k); v.resize(k, sol+1); for (auto &x: v) { cout<<x<<"\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 72 ms | 5012 KB | Output is correct |
2 | Correct | 69 ms | 4928 KB | Output is correct |
3 | Correct | 54 ms | 5016 KB | Output is correct |
4 | Correct | 55 ms | 5128 KB | Output is correct |
5 | Correct | 66 ms | 3812 KB | Output is correct |
6 | Correct | 30 ms | 356 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 10032 ms | 7244 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 10051 ms | 9292 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 10051 ms | 9292 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 72 ms | 5012 KB | Output is correct |
2 | Correct | 69 ms | 4928 KB | Output is correct |
3 | Correct | 54 ms | 5016 KB | Output is correct |
4 | Correct | 55 ms | 5128 KB | Output is correct |
5 | Correct | 66 ms | 3812 KB | Output is correct |
6 | Correct | 30 ms | 356 KB | Output is correct |
7 | Execution timed out | 10027 ms | 3920 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 72 ms | 5012 KB | Output is correct |
2 | Correct | 69 ms | 4928 KB | Output is correct |
3 | Correct | 54 ms | 5016 KB | Output is correct |
4 | Correct | 55 ms | 5128 KB | Output is correct |
5 | Correct | 66 ms | 3812 KB | Output is correct |
6 | Correct | 30 ms | 356 KB | Output is correct |
7 | Execution timed out | 10032 ms | 7244 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |