D - Axis-Parallel Rectangle


Time limit : 2sec / Memory limit : 256MB

Score : 400 points

Problem Statement

We have N points in a two-dimensional plane.
The coordinates of the i-th point (1≤iN) are (xi,yi).
Let us consider a rectangle whose sides are parallel to the coordinate axes that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the interior.
Find the minimum possible area of such a rectangle.

Constraints

  • 2≤KN≤50
  • −109≤xi,yi≤109(1≤iN)
  • xixj(1≤i<jN)
  • yiyj(1≤i<jN)
  • All input values are integers. (Added at 21:50 JST)

Input

Input is given from Standard Input in the following format:

N K
x1 y1
:
xN yN

Output

Print the minimum possible area of a rectangle that satisfies the condition.


Sample Input 1

Copy
4 4
1 4
3 3
6 2
8 1

Sample Output 1

Copy
21

One rectangle that satisfies the condition with the minimum possible area has the following vertices: (1,1)(8,1)(1,4) and (8,4).
Its area is (8−1)×(4−1)=21.


Sample Input 2

Copy
4 2
0 0
1 1
2 2
3 3

Sample Output 2

Copy
1

Sample Input 3

Copy
4 3
-1000000000 -1000000000
1000000000 1000000000
-999999999 999999999
999999999 -999999999
Sample Output 3
3999999996000000001
Watch out for integer overflows.
 
 
 
// N 个点,选出一个最小的矩形,包括至少 k 个点,求这最小的矩形的面积
// 枚举,疯狂枚举就行
 #include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define INF 0x3f3f3f3f3f3f3f3f
#define LL long long
#define MX 55
struct Node
{
LL x, y;
bool operator < (const Node &b)const{
return x<b.x;
}
}pt[MX]; int k, n; int main()
{
scanf("%d%d",&n,&k);
for (int i=;i<=n;i++)
scanf("%lld%lld",&pt[i].x, &pt[i].y);
sort(pt+,pt++n);
LL area = INF;
for (int i=;i<=n;i++)
{
for (int j=i+;j<=n;j++)
{
LL miny = min(pt[i].y, pt[j].y);
LL maxy = max(pt[i].y, pt[j].y);
for (int q=;q<=n;q++)
{
if (pt[q].y>maxy||pt[q].y<miny) continue;
int tot = ;
for (int z=q;z<=n;z++)
{
if (pt[z].y>maxy||pt[z].y<miny) continue;
tot++;
if (tot>=k)
area = min(area, (maxy-miny)*(pt[z].x-pt[q].x));
}
}
}
}
printf("%lld\n",area);
return ;
}
 
 

Axis-Parallel Rectangle的更多相关文章

  1. Gym 100463D Evil DFS

    Evil Time Limit: 5 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463/attachments Descri ...

  2. Codeforces Gym 100463D Evil DFS

    Evil Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463/attachments Descr ...

  3. [Swift]LeetCode223. 矩形面积 | Rectangle Area

    Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...

  4. HDUOJ-------2493Timer(数学 2008北京现场赛H题)

    Timer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  5. UVALIVE 4330 Timer

    Description   Recently, some archaeologists discovered an ancient relic on a small island in the Pac ...

  6. gnulpot

    gnulpot Table of Contents 1. Label position 2. coordinates 3. Symbols 4. key 4.1. key position 4.2. ...

  7. Codeforces Round #172 (Div. 2) C. Rectangle Puzzle 数学题几何

    C. Rectangle Puzzle Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/281/p ...

  8. Codeforces--630E--A rectangle(规律)

     E - A rectangle Crawling in process... Crawling failed Time Limit:500MS     Memory Limit:65536KB  ...

  9. Rectangle Puzzle CodeForces - 281C (几何)

    You are given two rectangles on a plane. The centers of both rectangles are located in the origin of ...

  10. 1266 - Points in Rectangle

    1266 - Points in Rectangle    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 3 ...

随机推荐

  1. Js中数组的追加

    Concat arrayObject.concat(arrayX,arrayX,......,arrayX) 常用于 加载更多 ,数组的追加.

  2. win10系统怎样手动安装cab更新补丁

    win10系统怎样手动安装cab更新补丁 1. 把所有补丁放进一个文件夹 例如 C:\UPDATE2. 以管理员运行命令提示符 3. 输入以下命令後按 Enterdism /online /add-p ...

  3. 绘制 SVG

    工具网址:http://svg123.com/ 画布 点击画布,在页面的右侧我们可以调整画布属性 点击属性,滚动滑轮可以微调 或者直接双击修改属性值 工具栏 左侧工具栏 就像画图的工具栏一样 形状库 ...

  4. Photoshop - 描边

    描边在后期的UI制作的时候会比较少用,因为有一些缺陷,可以用选取收缩 1.快捷键E + S  (菜单栏-编辑-描边.photoshop cc) 2.使用图层样式进行描边(双击图层列表区域,图层缩略图的 ...

  5. Flume、Kafka、Storm结合

    Todo: 对Flume的sink进行重构,调用kafka的消费生产者(producer)发送消息; 在Sotrm的spout中继承IRichSpout接口,调用kafka的消息消费者(Consume ...

  6. spring学习笔记(六)

    1.配置环绕通知 需要实现的接口为  MethodInterceptor   代码举例 package com.huawei.aop; import org.aopalliance.intercept ...

  7. Android应用TranslateAnimation移动之后,利用视图的setLayoutPara

    Android中利用TranslateAnimation移动时,不设置mTranslateAnimation.setFillAfter(true);,而利用视图的setLayoutParams来重新定 ...

  8. unity, Invoke延迟执行

    参考:http://blog.christianhenschel.com/2013/05/15/how-to-do-delayed-function-calls-in-unity3d-one-line ...

  9. FastDFS单机搭建以及java客户端Demo

    http://blog.csdn.net/u012453843/article/details/69951920 http://blog.csdn.net/xyang81/article/detail ...

  10. hadoop_百科

    一.发音是:[hædu:p]. 二.简介:Hadoop是一个由Apache基金会所开发的分布式系统基础架构.用户可以在不了解分布式底层细节的情况下,开发分布式程序.充分利用集群的威力进行高速运算和存储 ...