#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int maxn=1e4+9;
int x[maxn],y[maxn];
struct D
{
int x,y;
bool operator <(const D &xx)const
{
if(x==xx.x)
return y<xx.y;
return x<xx.x;
}
}point[maxn]; int abs(int a)
{
if(a<0) return -a;
return a;
} int main()
{
// freopen("in.txt","r",stdin);
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d %d",&x[i],&y[i]);
point[i].x=x[i];
point[i].y=y[i];
}
sort(x+1,x+1+n);
sort(y+1,y+1+n);
sort(point+1,point+1+n);
int ans=0;
long long sum=0;
if(n&1||(x[n>>1]==x[n+2>>1]&&y[n>>1]==y[n+2>>1]))
{
bool flag=false;
int xx=x[n+1>>1],yy=y[n+1>>1];
for(int k=1;k<=n;k++)
if(point[k].x==xx&&point[k].y==yy)
flag=true;
if(!flag)
{
for(int i=1;i<=n;i++)
{
sum+=abs(x[i]-xx);
sum+=abs(y[i]-yy);
}
printf("%lld %d\n",sum,1);
}
else
{
for(int i=1;i<=n;i++)
{
sum+=abs(x[i]-(xx+1));
sum+=abs(y[i]-yy);
}
long long ret=sum,tmp=1;
sum=0;
for(int i=1;i<=n;i++)
{
sum+=abs(x[i]-(xx-1));
sum+=abs(y[i]-yy);
}
if(sum==ret) tmp++;
else if(sum<ret) ret=sum;
sum=0;
for(int i=1;i<=n;i++)
{
sum+=abs(x[i]-xx);
sum+=abs(y[i]-(yy+1));
}
if(sum==ret) tmp++;
else if(sum<ret) ret=sum;
sum=0;
for(int i=1;i<=n;i++)
{
sum+=abs(x[i]-xx);
sum+=abs(y[i]-(yy-1));
}
if(sum==ret) tmp++;
else if(sum<ret) ret=sum;
printf("%lld %d\n",sum,tmp);
}
}
else
{
for(int i=1;i<=n;i++)
{
sum+=abs(x[i]-x[n>>1]);
sum+=abs(y[i]-y[n>>1]);
}
int k=1;
for(int i=x[n>>1];i<=x[n+2>>1];i++)
for(int j=y[n>>1];j<=y[n+2>>1];j++)
{
for(;point[k].x<i||(point[k].x==i&&point[k].y<j);k++);
if(point[k].x!=i||point[k].y!=j) ans++;
}
printf("%lld %d\n",sum,ans);
}
return 0;
}

poj 3269 Building A New Barn的更多相关文章

  1. Bzoj 1696: [Usaco2007 Feb]Building A New Barn新牛舍 中位数,数学

    1696: [Usaco2007 Feb]Building A New Barn新牛舍 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 394  Solve ...

  2. HDU 1815, POJ 2749 Building roads(2-sat)

    HDU 1815, POJ 2749 Building roads pid=1815" target="_blank" style="">题目链 ...

  3. [USACO07FEB]新牛棚Building A New Barn

    洛谷题目链接:[USACO07FEB]新牛棚Building A New Barn 题目描述 After scrimping and saving for years, Farmer John has ...

  4. poj 2749 Building roads (二分+拆点+2-sat)

    Building roads Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6229   Accepted: 2093 De ...

  5. poj 3625 Building Roads

    题目连接 http://poj.org/problem?id=3625 Building Roads Description Farmer John had just acquired several ...

  6. poj 2031 Building a Space Station【最小生成树prime】【模板题】

    Building a Space Station Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5699   Accepte ...

  7. POJ 2031 Building a Space Station【经典最小生成树】

    链接: http://poj.org/problem?id=2031 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...

  8. [USACO17JAN]Building a Tall Barn建谷仓

    题目描述 Farmer John is building a brand new, NNN -story barn, with the help of his KKK cows ( 1≤N≤K≤101 ...

  9. POJ 2031 Building a Space Station

    3维空间中的最小生成树....好久没碰关于图的东西了.....              Building a Space Station Time Limit: 1000MS   Memory Li ...

随机推荐

  1. 在linux中限制用户ftp访问权限

    1.环境:redhat linux企业版4.ftp为vsftp.被限制用户名为aaa.被限制路径为/bbb.2.建用户:在root用户下,相继进行如下操作       adduser aaa      ...

  2. struts2中使用json插件实现ajax交互

    json插件可以简单的实现ajax交互,避免了使用struts2-dojo-plugin.jar包时带来的struts2.x版本冲突问题.并且减少了使用ajax标签时需要的繁琐的配置包括web.xml ...

  3. Swift 函数和类

    函数: func sayHello(personName:String,z:Int)->{ return "hello"+personName+z } print(sayHe ...

  4. boa,thttp服务器安装,配置,测试

    boa 1, SERVER_ROOT自定义,define.h头文件中,默认“/etc/boa" 2,./configure 3,修改CC,默认CC=gcc,make 4,error util ...

  5. spring常量值注入

    <context:property-placeholder location="classpath:resources/*.properties" /> @Value( ...

  6. VUE.JS组件化

    VUE.JS组件化 前言 公司目前制作一个H5活动,特别是有一定统一结构的活动,都要码一个重复的轮子.后来接到一个基于模板的活动设计系统的需求,便有了下面的内容.借油开车. 组件化 需求一到,接就是怎 ...

  7. SQL Server FileStream优点与不足

    LOB优点: 1.保证大对象的事务一致性. 2.备份与还原包括大数据对象,可以对它进行时点恢复. 3.所有数据都可以使用一种存储与查询环境. LOB不足: 1.大型对象在缓存中占非常大的缓存区. 2. ...

  8. ODI利用goldengate实现增量数据捕获

    ODI利用goldengate实现增量数据捕获 上个月,Oracle发布了ODI的最新版本10.1.3.6_02,其中增加了针对采用goldengate获取源数据库增量变化的知识模块,这样当系统需要实 ...

  9. ViewTreeObserver简介

    Android ViewTreeObserver简介 一.结构 public final class ViewTreeObserver extends Object java.lang.Object ...

  10. rsyslog masg和rawmsg的区别

    msg the MSG part of the message (aka "the message" ;)) message 的MSG 部分 rawmsg the message ...