# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
992353 | Brinyon | Road Construction (JOI21_road_construction) | C++14 | 10048 ms | 8712 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>
#define MAXN 250001
using namespace std;
struct point{
long long x,y;
};
long long dist(point a,point b){
return abs(a.x-b.x)+abs(a.y-b.y);
}
long long n,k;
point a[MAXN];
bool cmp(point a,point b){
if(a.x==b.x) return a.y<b.y;
return a.x<b.x;
}
priority_queue<long long> pq;
int main(){
cin>>n>>k;
for(long long i=0;i<n;i++){
long long x,y;
cin>>a[i].x>>a[i].y;
}
sort(a,a+n,cmp);
for(long long i=0;i<n;i++){
for(long long i1=i-1;i1>=0;i1--){
long long dst=dist(a[i],a[i1]);
if(pq.size()<k) pq.push(dst);
else if(dst<pq.top()){
pq.push(dst);
pq.pop();
}
}
}
vector<long long> v;
while(!pq.empty()){
v.push_back(pq.top());
pq.pop();
}
for(long long i=v.size()-1;i>=0;i--){
cout<<v[i]<<"\n";
}
return 0;
}
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... |