Submission #1315510

#TimeUsernameProblemLanguageResultExecution timeMemory
1315510vlomaczkRoad Construction (JOI21_road_construction)C++20
0 / 100
4111 ms2108152 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct Point {
	ll x, y;
};

ll M = 250'010;
vector<ll> cnt(M,1);
ll n;
ll inf = 1e18;

vector<Point> pkt;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	ll k;
	cin >> n >> k;
	pkt.resize(n);
	for(ll i=0; i<n; ++i) {
		ll x,y;
		cin >> x >> y;
		pkt[i] = {x+y,x-y};
	}
	priority_queue<pair<ll, ll>> pq;
	for(ll j=0; j<n; ++j) {
		auto[x,y] = pkt[j];
		for(int i=0; i<n; ++i) {
			if(i==j) continue;
			pq.push({-max(abs(pkt[i].x-x), abs(pkt[i].y-y)), 0});
		}
	}
	vector<int> ans;
	for(ll ile=0; ile<2*k; ++ile){
		ans.push_back(-pq.top().first);
		ll i =pq.top().second;
		pq.pop();
	}
	for(int i=0; i<ans.size(); i+=2) cout << ans[i] << "\n";

	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...