# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1040260 | MarwenElarbi | Road Construction (JOI21_road_construction) | C++17 | 849 ms | 15424 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>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define ll long long
#define pb push_back
#define fi first
#define se second
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main(){
optimise;
int n,k;
cin>>n>>k;
vector<pair<ll,ll>> tab(n);
for (int i = 0; i < n; ++i)
{
cin>>tab[i].fi>>tab[i].se;
}
sort(tab.begin(),tab.end());
priority_queue<ll> pq;
for (int i = 0; i < n; ++i)
{
for (int j = i-1; j >= max(0,i-1000) ; j--)
{
ll cur=abs(tab[i].fi-tab[j].fi)+abs(tab[i].se-tab[j].se);
if(pq.size()<k) pq.push(cur);
else{
if(pq.top()>cur){
pq.pop();
pq.push(cur);
}
}
}
}
vector<ll> ans(k);
for (int i = 0; i < k; ++i)
{
ans[i]=pq.top();
pq.pop();
}
reverse(ans.begin(),ans.end());
for (int i = 0; i < k; ++i)
{
cout <<ans[i]<<endl;
}
}
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... |