# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
893413 | 2023-12-27T04:35:36 Z | abushbandit_1 | Road Construction (JOI21_road_construction) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define all(x) x.begin(),x.end() #define ff first #define ss second const long long INF = 1e18; const int N = 1e5 + 1; signed main(){ int n; cin >> n; int k; cin >> k; int cnt = 0; int x[n],y[n]; for(int i = 0;i < n;i++){ cin >> x[i] >> y[i]; mp[x[i]]++; if(y[i] == y[0]){ cnt++; } } if(cnt == n){ sort(x,x + n); vector<int> v; int j = 1,h = k; while(k > 0){ for(int i = 0;i < n - j;i++){ v.pb(abs(abs(x[i + j]) - abs(x[i]))); k--; } j++; } k = h; sort(all(v)); for(int i = 0;i < k;i++){ cout << v[i] << "\n"; } } else if(n <= 1000){ vector<int> v; for(int i = 0;i < n;i++){ for(int j = i + 1;j < n;j++){ v.pb(abs(x[i] - x[j]) + abs(y[i] - y[j])); } } sort(all(v)); for(int i = 0;i < k;i++){ cout << v[i] << "\n"; } } else if(k == 1){ } else if(k <= 10){ } else { } }