#include <bits/stdc++.h>
using namespace std;
#include <ext/rope>
using namespace __gnu_cxx;
// #pragma comment(linker, "/stack:2000000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define precise(a) cout<<fixed<<setprecision(a)
#define sz size()
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
// t1
const ll mod = ll(1e9)+7; //(b + (a%b)) % b (to mod -1%(10^9+7) correctly in c++ its -1 but its suppose to be 10^9+6
const ll MOD = 998244353; // (a%mod)*(binpow(b,mod-2,mod) = (a/b)%mod
const ll N = ll(5e5)+10;
const ll K = 17;
const ll inf = 1e18;
const ld eps = 1e-15L;
//const ll B = 316;
ll lcm(ll a, ll b){ return (a / __gcd(a,b)) * b; }
//const ld P = acos(-1.0);
// ll binpow(ll a, ll b, ll m){ ll res=1;a%=m; while(b>0){ if(b&1)res=(res*a)%m; a=(a*a)%m; b/=2; } return res%m;}
ld binpow(ld a, ll b){ ld res=1; while(b>0){ if(b&1)res=(res*a); a=(a*a); b/=2; } return res;}
void precalc() {
}
ll getdis(ll x1, ll y1, ll x2, ll y2) {
return abs(x2-x1)+abs(y2-y1);
}
void Baizho()
{
ll n, k; cin>>n>>k;
pll a[n+11];
ll sec = 2001;
for(ll i=1; i<=n; i++) {
cin>>a[i].ff>>a[i].ss;
// if(a[i].ss!=0) case2 = 0;
}
sort(a+1, a+n+1);
multiset<ll> st;
for(ll i=1; i<=n-1; i++) {
ll p = i;
for(ll j = i+1; j<=i+sec && j<=n; j++) {
// cout<<p<<" "<<j<<endl;
ll x1 = a[p].ff, y1 = a[p].ss, x2 = a[j].ff, y2 = a[j].ss;
ll dist = getdis(x1, y1, x2, y2);
st.insert(dist);
while(st.sz>k) {
auto x = st.end();
x--;
st.erase(x);
}
}
}
for(auto x : st) cout<<x<<"\n";
}
int main() {
// Freopen("div7");
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
precalc();
int ttt = 1;
// cin>>ttt;
for(int i=1; i<=ttt; i++) { Baizho();}
}
Compilation message
road_construction.cpp: In function 'void Baizho()':
road_construction.cpp:63:24: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
63 | while(st.sz>k) {
| ~~~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
274 ms |
14652 KB |
Output is correct |
2 |
Correct |
258 ms |
14540 KB |
Output is correct |
3 |
Correct |
131 ms |
14676 KB |
Output is correct |
4 |
Correct |
139 ms |
14688 KB |
Output is correct |
5 |
Correct |
232 ms |
13588 KB |
Output is correct |
6 |
Correct |
28 ms |
420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
10074 ms |
15940 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
10038 ms |
4180 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
10038 ms |
4180 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
274 ms |
14652 KB |
Output is correct |
2 |
Correct |
258 ms |
14540 KB |
Output is correct |
3 |
Correct |
131 ms |
14676 KB |
Output is correct |
4 |
Correct |
139 ms |
14688 KB |
Output is correct |
5 |
Correct |
232 ms |
13588 KB |
Output is correct |
6 |
Correct |
28 ms |
420 KB |
Output is correct |
7 |
Execution timed out |
10024 ms |
13516 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
274 ms |
14652 KB |
Output is correct |
2 |
Correct |
258 ms |
14540 KB |
Output is correct |
3 |
Correct |
131 ms |
14676 KB |
Output is correct |
4 |
Correct |
139 ms |
14688 KB |
Output is correct |
5 |
Correct |
232 ms |
13588 KB |
Output is correct |
6 |
Correct |
28 ms |
420 KB |
Output is correct |
7 |
Execution timed out |
10074 ms |
15940 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |