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. 倍福TwinCAT(贝福Beckhoff)常见问题(FAQ)-人机界面快速入门 TC2

    创建最简单的静态文本,就像是label,就只需要绘制一个矩形框,然后填写Text,取消边框即可(你也可以设置自定义字体)   创建动态的文本框,就像是textbox,需要设置这个矩形框的Text为%d ...

  2. unity web项目发布服务器Data file is corrupt (not a Unity W

    楼上问题需要在iis 中配置MIME 加一个 .unity3d MIME类型:application/octet-stream http://www.cnblogs.com/123ing/p/3913 ...

  3. Django——django1.6 基于类的通用视图

    最初 django 的视图都是用函数实现的,后来开发出一些通用视图函数,以取代某些常见的重复性代码.通用视图就像是一些封装好的处理器,使用它们的时候只须要给出特定的参数集即可,不必关心具体的实现.各种 ...

  4. 小程序flex属性两边边距自适应

    使用flex属性两边边距自适应解决方案   Justify-content:center   文章来源:刘俊涛的博客 地址:http://www.cnblogs.com/lovebing 欢迎关注,有 ...

  5. lodash forIn forOwn 遍历对象属性

    _.forIn(object, [iteratee=_.identity]) 使用 iteratee 遍历对象的自身和继承的可枚举属性. function Foo() { this.a = 1; th ...

  6. Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.cache.ehcache.EhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFac

    警告: Exception encountered during context initialization - cancelling refresh attempt: org.springfram ...

  7. 工作总结 input 限制字数 textarea限制字数

    最大能输入50个字 复制粘贴也不行 <textarea maxlength="50"  class=" smallarea" cols="60& ...

  8. Atitit  文件上传  架构设计 实现机制 解决方案  实践java php c#.net js javascript  c++ python

    Atitit  文件上传  架构设计 实现机制 解决方案  实践java php c#.net js javascript  c++ python 1. 上传的几点要求2 1.1. 本地预览2 1.2 ...

  9. Skyscrapers Aren’t Scalable

     Skyscrapers Aren't Scalable Michael Nygard WE oFTEn HEAR SoFTWARE EnginEERing CoMpAREd to building ...

  10. C++语言基础(2)-new和delete操作符

    在C语言中,动态分配内存用 malloc() 函数,释放内存用 free() 函数.如下所示: ); //分配10个int型的内存空间 free(p); //释放内存 在C++中,这两个函数仍然可以使 ...