Submission #1040259

#TimeUsernameProblemLanguageResultExecution timeMemory
1040259MarwenElarbiRoad Construction (JOI21_road_construction)C++17
6 / 100
786 ms7664 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define ll long long #define pb push_back #define fi first #define se second #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; int main(){ optimise; int n,k; cin>>n>>k; vector<pair<int,int>> tab(n); for (int i = 0; i < n; ++i) { cin>>tab[i].fi>>tab[i].se; } sort(tab.begin(),tab.end()); priority_queue<ll> pq; for (int i = 0; i < n; ++i) { for (int j = i-1; j >= max(0,i-1000) ; j--) { ll cur=abs(tab[i].fi-tab[j].fi)+abs(tab[i].se-tab[j].se); if(pq.size()<k) pq.push(cur); else{ if(pq.top()>cur){ pq.pop(); pq.push(cur); } } } } vector<ll> ans(k); for (int i = 0; i < k; ++i) { ans[i]=pq.top(); pq.pop(); } reverse(ans.begin(),ans.end()); for (int i = 0; i < k; ++i) { cout <<ans[i]<<endl; } }

Compilation message (stderr)

road_construction.cpp: In function 'int main()':
road_construction.cpp:26:25: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |             if(pq.size()<k) pq.push(cur);
      |                ~~~~~~~~~^~
#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...