Submission #990833

#TimeUsernameProblemLanguageResultExecution timeMemory
99083312345678Road Construction (JOI21_road_construction)C++17
6 / 100
478 ms57576 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int nx=250005; ll n, k, x[nx], y; set<pair<ll, ll>> s; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>k; for (int i=0; i<n; i++) cin>>x[i]>>y; sort(x, x+n); priority_queue<tuple<ll, ll, ll>, vector<tuple<ll, ll, ll>>, greater<tuple<ll, ll, ll>>> pq; for (int i=0; i<n-1; i++) pq.push({x[i+1]-x[i], i, i+1}), s.insert({i, i+1}); for (int t=1; t<=k; t++) { auto [d, a, b]=pq.top(); pq.pop(); cout<<d<<'\n'; if (a!=0&&s.find({a-1, b})==s.end()) pq.push({x[b]-x[a-1], a-1, b}), s.insert({a-1, b}); if (b!=n-1&&s.find({a, b+1})==s.end()) pq.push({x[b+1]-x[a], a, b+1}), s.insert({a, b+1}); } }
#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...