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 ll long long
const int nx=1e3+5;
ll n, k;
pair<ll, ll> p[nx];
priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
priority_queue<ll, vector<ll>, greater<ll>> dp[nx];
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>k;
for (int i=0; i<n; i++) cin>>p[i].first>>p[i].second;
sort(p, p+n);
//for (int i=0; i<n; i++) cout<<"points "<<p[i].first<<' '<<p[i].second<<'\n';
for (int i=0; i<n; i++) for (int j=0; j<i; j++) dp[i].push(p[i].first-p[j].first+abs(p[i].second-p[j].second));
for (int i=0; i<n; i++) if (!dp[i].empty()) pq.push({dp[i].top(), i}), dp[i].pop();
for (int t=1; t<=k; t++)
{
auto [d,idx]=pq.top();
pq.pop();
cout<<d<<'\n';
if (!dp[idx].empty()) pq.push({dp[idx].top(), idx}), dp[idx].pop();
}
}
# | 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... |