#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>dist;
for(int i=1;i<n;i++){
dist.insert(a[i].x-a[i-1].x);
}
int ind=0;
for(ll to:dist){
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();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
422 ms |
26364 KB |
Output is correct |
2 |
Correct |
444 ms |
26392 KB |
Output is correct |
3 |
Correct |
177 ms |
14696 KB |
Output is correct |
4 |
Correct |
165 ms |
14708 KB |
Output is correct |
5 |
Correct |
312 ms |
25212 KB |
Output is correct |
6 |
Correct |
184 ms |
23704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
273 ms |
20284 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10108 ms |
357176 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10108 ms |
357176 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
422 ms |
26364 KB |
Output is correct |
2 |
Correct |
444 ms |
26392 KB |
Output is correct |
3 |
Correct |
177 ms |
14696 KB |
Output is correct |
4 |
Correct |
165 ms |
14708 KB |
Output is correct |
5 |
Correct |
312 ms |
25212 KB |
Output is correct |
6 |
Correct |
184 ms |
23704 KB |
Output is correct |
7 |
Execution timed out |
10063 ms |
354508 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
422 ms |
26364 KB |
Output is correct |
2 |
Correct |
444 ms |
26392 KB |
Output is correct |
3 |
Correct |
177 ms |
14696 KB |
Output is correct |
4 |
Correct |
165 ms |
14708 KB |
Output is correct |
5 |
Correct |
312 ms |
25212 KB |
Output is correct |
6 |
Correct |
184 ms |
23704 KB |
Output is correct |
7 |
Incorrect |
273 ms |
20284 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |