Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
30350 | LYLAKIOI | 【S】T3 | C++ | 运行超时 | 40 | 2000 MS | 304 KB | 1110 | 2024-06-23 18:45:39 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define p_b push_back #define pi pair<int,int> #define p1 first #define p2 second #define m_p make_pair using namespace std; typedef long long ll; const int maxn=6e5+10; inline ll read(){ ll x=0;short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; } int n,k; struct node { int x,y; }d[maxn]; ll calc(int px,int py){ vector<ll>S; up(i,1,n)S.p_b((ll)abs(px-d[i].x)+(ll)abs(py-d[i].y)); sort(S.begin(),S.end());ll res=0; up(i,0,k-1)res+=S[i]; return res; } void slv(){ n=read(),k=read(); up(i,1,n)d[i].x=read(),d[i].y=read(); ll res=1e18; up(i,1,n)up(j,1,n)res=min(res,calc(d[i].x,d[j].y)); cout<<res; }int main(){ // freopen("dating.in","r",stdin); // freopen("dating.out","w",stdout); slv(); fclose(stdin); fclose(stdout); //cerr<<clock()*1.0/CLOCKS_PER_SEC<<"s\n"; return 0; }