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

【题意】

让你找到一个各边和坐标轴平行的矩形。使得这个矩形包含至少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. Mahout的推荐系统

    Mahout的推荐系统 什么是推荐系统 为什使用推荐系统 推荐系统中的算法 什么是推荐系统 为什么使用推荐系统? 促进厂商商品销售,帮助用户找到想要的商品 推荐系统无处不在,体现在生活的各个方面 图书 ...

  2. Kinect 开发 —— Kinect for windows SDK

    开发 —— 基本的SDK和Windows 编程技巧(彩色图像视频流,深度图像视频流的采集,骨骼跟踪,音频处理,语音识别API) 深度数据,就是Kinect的精髓和灵魂,很多问题都转换为深度图像的模式识 ...

  3. 洛谷——P1209 [USACO1.3]修理牛棚 Barn Repair

    https://www.luogu.org/problem/show?pid=1209 题目描述 在一个夜黑风高,下着暴风雨的夜晚,farmer John的牛棚的屋顶.门被吹飞了. 好在许多牛正在度假 ...

  4. highcharts 阶梯图表并填充颜色(自己觉得:直角折线图表)

    例如以下:普通阶梯图 $(function () { $('#container').highcharts({         title: {         text: '普通阶梯图'       ...

  5. 程序猿的量化交易之路(14)--Cointrader数据表(2)

    Cointrader表结构 转载须注明出处:http://blog.csdn.net/minimicall?viewmode=contents,http://cloudtrader.top 设置(se ...

  6. actionBar-双行字体大小修改

    <style name="BackupRestore.Theme.Person" parent="@style/BackupRestore.Theme"& ...

  7. Zabbix主动代理模式 + 主动模式agent客户端

    2.1.1 安装软件 ]# rpm -qa zabbix* zabbix-proxy-sqlite3-3.4.15-1.el7.x86_64 zabbix-proxy-mysql-3.4.15-1.e ...

  8. 外部事件触发调用对象方法时this指向问题

    问题如下: var obj = { name: 'dang', test:function(){ alert(this.name); } }; obj.test(); //这样是可以的 $('.box ...

  9. BZOJ2555: SubString(后缀自动机,LCT维护Parent树)

    Description 懒得写背景了,给你一个字符串init,要求你支持两个操作 (1):在当前字符串的后面插入一个字符串 (2):询问字符串s在当前字符串中出现了几次?(作为连续子串) 你必须在线支 ...

  10. 今天发现里一个非常好用的Listbox自绘类,带不同文字字体和图片,觉得很有必要记下来

    代码简写 MyListBox.h class CUseListBox : public CListBox { typedef struct _ListBox_Data { CString strApp ...