#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ull unsigned ll
#define pb push_back
#define epb emplace_back
using namespace std;
struct Point{
ll x,y;
Point(ll x,ll y):x(x),y(y){}
Point(){
}
};
ll dist(Point A,Point B){
return abs(A.x-B.x)+abs(A.y-B.y);
}
bool check(vector<Point>a){
for(Point A:a){
if(A.y!=0)return false;
}
return true;
}
bool comp(Point A,Point B){
if(A.x==B.x)return A.y<B.y;
return A.x<B.x;
}
void solve(){
int n;cin>>n;
int k;cin>>k;
vector<Point>a(n);
for(int i=0;i<n;i++)cin>>a[i].x>>a[i].y;
sort(a.begin(),a.end(),comp);
if(check(a)){
multiset<ll>d;
for(int i=1;i<n;i++){
if(d.size()>=k)break;
for(int j=i;j<n;j++){
d.insert(dist(a[j],a[j-i]));
}
}
int ind=0;
for(ll to:d){
if(ind>=k)break;
cout<<to<<"\n";
ind++;
}
return;
}
multiset<ll>d;
for(int i=0;i<n;i++){
for(int j=0;j<i;j++){
d.insert(dist(a[i],a[j]));
}
}
int ind=0;
for(ll to:d){
if(ind>=k)break;
cout<<to<<"\n";
ind++;
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
solve();
}
Compilation message
road_construction.cpp: In function 'void solve()':
road_construction.cpp:42:24: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
42 | if(d.size()>=k)break;
| ~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
513 ms |
26484 KB |
Output is correct |
2 |
Correct |
400 ms |
26332 KB |
Output is correct |
3 |
Correct |
187 ms |
14660 KB |
Output is correct |
4 |
Correct |
159 ms |
14624 KB |
Output is correct |
5 |
Correct |
301 ms |
25148 KB |
Output is correct |
6 |
Correct |
177 ms |
23700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
580 ms |
31968 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10080 ms |
347872 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10080 ms |
347872 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
513 ms |
26484 KB |
Output is correct |
2 |
Correct |
400 ms |
26332 KB |
Output is correct |
3 |
Correct |
187 ms |
14660 KB |
Output is correct |
4 |
Correct |
159 ms |
14624 KB |
Output is correct |
5 |
Correct |
301 ms |
25148 KB |
Output is correct |
6 |
Correct |
177 ms |
23700 KB |
Output is correct |
7 |
Execution timed out |
10112 ms |
347508 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
513 ms |
26484 KB |
Output is correct |
2 |
Correct |
400 ms |
26332 KB |
Output is correct |
3 |
Correct |
187 ms |
14660 KB |
Output is correct |
4 |
Correct |
159 ms |
14624 KB |
Output is correct |
5 |
Correct |
301 ms |
25148 KB |
Output is correct |
6 |
Correct |
177 ms |
23700 KB |
Output is correct |
7 |
Incorrect |
580 ms |
31968 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |