【链接】 我是链接,点我呀:)

【题意】

让你找到一个各边和坐标轴平行的矩形。使得这个矩形包含至少K个点。
且这个矩形的面积最小。

【题解】

把所有的“关键点“”都找出来。
然后枚举任意两个点作为矩形的对角。
然后看他是不是包含了至少K个点即可。

【代码】

    #include <bits/stdc++.h>
using namespace std; const int N = 50; int n, k;
long long ans = -1;
int xx[N + 10], yy[N + 10];
pair <int, int> a[N*N + 10]; int main()
{
//freopen("F:\\rush.txt", "r", stdin);
scanf("%d%d", &n, &k);
for (int i = 1; i <= n; i++)
scanf("%d%d", &xx[i], &yy[i]);
int nn = 0;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
a[++nn] = make_pair(xx[i], yy[j]);
for (int i = 1; i <= nn; i++)
{
for (int j = i+1; j <= nn; j++)
{
int x1 = min(a[i].first, a[j].first);
int x2 = max(a[i].first, a[j].first);
int y1 = min(a[i].second, a[j].second);
int y2 = max(a[i].second, a[j].second);
int num = 0;
for (int kk = 1; kk <= n; kk++)
if (x1 <= xx[kk] && xx[kk] <= x2 && y1 <= yy[kk] && yy[kk] <= y2)
num++;
if (num >= k)
{
long long s = 1LL * (x2 - x1)*(y2 - y1);
if (ans == -1)
ans = s;
else
ans = min(ans, s);
}
}
}
printf("%lld\n", ans);
return 0;
}

【AtCoder ABC 075 D】Axis-Parallel Rectangle的更多相关文章

  1. 【AtCoder ABC 075 C】Bridge

    [链接] 我是链接,点我呀:) [题意] 让你求出桥的个数 [题解] 删掉这条边,然后看看1能不能到达其他所有的点就可以了 [代码] #include <bits/stdc++.h> us ...

  2. 【AtCoder ABC 075 B】Minesweeper

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟,把#换成1 八个方向加一下就好. [代码] #include <bits/stdc++.h> using name ...

  3. 【AtCoder ABC 075 A】One out of Three

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map轻松搞定 [代码] #include <bits/stdc++.h> using namespace std; ...

  4. 【AtCoder Regular Contest 082】Derangement

    [链接]点击打开链接 [题意] 在这里写题意 [题解] 贪心. 连续一块的p[i]==i的话,对答案的贡献就应该为(这个连续块的长度+1)/2; 长度为1的也正确. (也即两两相邻的互换位置.) [错 ...

  5. 【Atcoder hbpc C 183】1=0.999...

    Atcoder hbpc C 题意:给n个循环小数或者有限小数,问其中有多少个互不相同的. 思路:我的思路比较繁琐. 首先我们考虑分数化小数:假设原来的数是\(a.b(c)\),那么这个分数就是\(a ...

  6. 【AtCoder Regular Contest 080E】Young Maids [堆][线段树]

    Young Maids Time Limit: 50 Sec  Memory Limit: 512 MB Description 给定一个排列,每次选出相邻的两个放在队头,要求字典序最小. Input ...

  7. 【AtCoder Grand Contest 007E】Shik and Travel [Dfs][二分答案]

    Shik and Travel Time Limit: 50 Sec  Memory Limit: 512 MB Description 给定一棵n个点的树,保证一个点出度为2/0. 遍历一遍,要求每 ...

  8. 【AtCoder Grand Contest 001F】Wide Swap [线段树][拓扑]

    Wide Swap Time Limit: 50 Sec  Memory Limit: 512 MB Description Input Output Sample Input 8 3 4 5 7 8 ...

  9. 【AtCoder Grand Contest 012C】Tautonym Puzzle [构造]

    Tautonym Puzzle Time Limit: 50 Sec  Memory Limit: 256 MB Description 定义一个序列贡献为1,当且仅当这个序列 由两个相同的串拼接而成 ...

随机推荐

  1. 2.Maven之(二)Maven生命周期

    转自:https://blog.csdn.net/u012152619/article/details/51473404 我们在开发项目的时候,不断地在编译.测试.打包.部署等过程,maven的生命周 ...

  2. 70.lambda表达式逻辑(二进制转换为为十进制)

    #include <iostream> #include <cstring> using namespace std; void main() { auto fun = []( ...

  3. Oracle primary key&foreign key

    --主键 alter table tablename1 add constraint pk_tablename1 primary key(column1);--增加数据表1的主键column1,如果是 ...

  4. canvas:画布

    画布有默认宽度,如果要自己设置宽带要写在属性上 列: <canvas id = "myCanvas" width = "600" height = &qu ...

  5. JS面向对象系列教程 — 对象的基本操作

    面向对象概述  面向对象(Object Oriented)简称OO,它是一种编程思维,用于指导我们如何应对各种复杂的开发场景. 这里说的对象(Object),意思就是事物,在面向对象的思维中,它将一 ...

  6. HDU 4107 Gangster

    Gangster Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 4 ...

  7. poj 1001 java大精度

    import java.io.* ; import java.math.* ; import java.util.* ; import java.text.* ; public class Main ...

  8. 漫话C++之string字符串类的使用(有汇编分析)

    C++中并不提倡继续使用C风格的字符串,而是为字符串定义了专门的类,名为string. 使用前的准备工作 在使用string类型时,需要包含string头文件,且string位于std命名空间内: # ...

  9. Elasticsearch之插件扩展

    Elasticsearch之插件介绍及安装 Elasticsearch之head插件安装之后的浏览详解 Elasticsearch之kopf插件安装之后的浏览详解 Elasticsearch-2.4. ...

  10. Spring中的AOP注解方式和XML方式

    应掌握内容:1. AOP的全名2. AOP的实现原理[静态代理和动态代理]3. 注解方式的配置4. 通知类型     A. 每种通知的特点和使用方式    B. 获取各种数据,方便日后操作5. 执行表 ...