Submission #945721

#TimeUsernameProblemLanguageResultExecution timeMemory
945721teacupRoad Construction (JOI21_road_construction)C++14
5 / 100
209 ms12452 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ii pair<int,int> typedef vector<int> vi; #define iii tuple<int,int,int> typedef vector<ii> vii; typedef vector<iii> viii; typedef map<int,int> mii; #ifndef debug #define cerr if (0) cerr #endif int N, K; vi X,Y; int32_t main(){ cin>>N>>K; for (int i=0; i<N; i++){ int a,b; cin>>a>>b; X.emplace_back(a); Y.emplace_back(b); } priority_queue<int, vi, greater<int>> PQ; if (N<=1000){ for (int i=0; i<N; i++){ for (int j=i+1; j<N; j++){ PQ.push(abs(X[i]-X[j])+abs(Y[i]-Y[j])); //cout<<i<<" "<<j<<abs(X[i]-X[j])+abs(Y[i]-Y[j])<<"\n"; } } }else{ sort(X.begin(), X.end()); for (int i=1; i<N; i++){ PQ.push(abs(X[i]-X[i-1])); } } for (int i=0; i<K; i++){ cout<<PQ.top()<<"\n"; PQ.pop(); } }
#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...