Submission #992353

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
9923532024-06-04 09:59:31BrinyonRoad Construction (JOI21_road_construction)C++14
32 / 100
10048 ms8712 KiB
#include<bits/stdc++.h>
#define MAXN 250001
using namespace std;
struct point{
long long x,y;
};
long long dist(point a,point b){
return abs(a.x-b.x)+abs(a.y-b.y);
}
long long n,k;
point a[MAXN];
bool cmp(point a,point b){
if(a.x==b.x) return a.y<b.y;
return a.x<b.x;
}
priority_queue<long long> pq;
int main(){
cin>>n>>k;
for(long long i=0;i<n;i++){
long long x,y;
cin>>a[i].x>>a[i].y;
}
sort(a,a+n,cmp);
for(long long i=0;i<n;i++){
for(long long i1=i-1;i1>=0;i1--){
long long dst=dist(a[i],a[i1]);
if(pq.size()<k) pq.push(dst);
else if(dst<pq.top()){
pq.push(dst);
pq.pop();
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

road_construction.cpp: In function 'int main()':
road_construction.cpp:20:19: warning: unused variable 'x' [-Wunused-variable]
   20 |         long long x,y;
      |                   ^
road_construction.cpp:20:21: warning: unused variable 'y' [-Wunused-variable]
   20 |         long long x,y;
      |                     ^
road_construction.cpp:27:25: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   27 |             if(pq.size()<k) pq.push(dst);
      |                ~~~~~~~~~^~
#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...