제출 #1040258

#제출 시각아이디문제언어결과실행 시간메모리
1040258MarwenElarbiRoad Construction (JOI21_road_construction)C++17
6 / 100
787 ms8652 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<int> pq; for (int i = 0; i < n; ++i) { for (int j = i-1; j >= max(0,i-1000) ; j--) { int 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<int> 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; } }

컴파일 시 표준 에러 (stderr) 메시지

road_construction.cpp: In function 'int main()':
road_construction.cpp:26:25: warning: comparison of integer expressions of different signedness: 'std::priority_queue<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...