#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std ;
const ll N = (1 << 30) ;
bool flag1 ;
signed main()
{
ios_base::sync_with_stdio( 0 ) ;
cin.tie( 0 ) ;
cout.tie( 0 ) ;
ll n, k ;
cin >> n >> k ;
pair<ll, ll> p[n + 1], py[n + 1] ;
vector<ll> v ;
for(ll i = 1 ; i <= n ; i++)
{
cin >> p[i].fi >> p[i].se ;
py[i] = {p[i].se, p[i].fi} ;
if(p[i].se)flag1 = 1 ;
}
if(n <= 1000)
{
for(ll i = 1 ; i <= n ; i++)
for(ll j = i + 1 ; j <= n ; j++)
v.push_back(abs(p[i].fi - p[j].fi) + abs(p[i].se - p[j].se)) ;
sort(v.begin(), v.end()) ;
for(ll i = 0 ; i < k ; i++)
cout << v[i] << '\n' ;
return 0 ;
}
if(k == 1)
{
ll ans = 1e18 ;
sort(p + 1, p + n + 1) ;
sort(py + 1, py + n + 1) ;
for(int i = 2 ; i <= n ; i++)
{
ans = min(ans, abs(p[i].fi - p[i - 1].fi) + abs(p[i].se - p[i - 1].se)) ;
ans = min(ans, abs(py[i].fi - py[i - 1].fi) + abs(py[i].se - py[i - 1].se)) ;
}
cout << ans << '\n' ;
return 0 ;
}
return 0 ;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
6996 KB |
Output is correct |
2 |
Correct |
52 ms |
6968 KB |
Output is correct |
3 |
Correct |
32 ms |
5000 KB |
Output is correct |
4 |
Correct |
33 ms |
5140 KB |
Output is correct |
5 |
Correct |
50 ms |
5828 KB |
Output is correct |
6 |
Correct |
18 ms |
4556 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
35 ms |
11064 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
84 ms |
13132 KB |
Output is correct |
2 |
Correct |
81 ms |
8268 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
76 ms |
8268 KB |
Output is correct |
5 |
Correct |
94 ms |
8252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
84 ms |
13132 KB |
Output is correct |
2 |
Correct |
81 ms |
8268 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
76 ms |
8268 KB |
Output is correct |
5 |
Correct |
94 ms |
8252 KB |
Output is correct |
6 |
Incorrect |
49 ms |
8276 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
6996 KB |
Output is correct |
2 |
Correct |
52 ms |
6968 KB |
Output is correct |
3 |
Correct |
32 ms |
5000 KB |
Output is correct |
4 |
Correct |
33 ms |
5140 KB |
Output is correct |
5 |
Correct |
50 ms |
5828 KB |
Output is correct |
6 |
Correct |
18 ms |
4556 KB |
Output is correct |
7 |
Incorrect |
18 ms |
5340 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
6996 KB |
Output is correct |
2 |
Correct |
52 ms |
6968 KB |
Output is correct |
3 |
Correct |
32 ms |
5000 KB |
Output is correct |
4 |
Correct |
33 ms |
5140 KB |
Output is correct |
5 |
Correct |
50 ms |
5828 KB |
Output is correct |
6 |
Correct |
18 ms |
4556 KB |
Output is correct |
7 |
Incorrect |
35 ms |
11064 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |