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

【题意】

让你找到一个各边和坐标轴平行的矩形。使得这个矩形包含至少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. modSecurity规则学习(一)——配置文件

    环境:modSecurity3.0,nignx1.13.8 modSecurity配置文件 1.nginx.conf server { listen ; modsecurity on; //启动mod ...

  2. Linux / Windows应用方案不完全对照表

    Linux/Windows应用方案不完全对照表 650) this.width=650;" border="0" src="http://img1.51cto. ...

  3. Android 将HTML5封装成android应用APK文件的几种方法

    越来越多的开发者热衷于使用html5+JavaScript开发移动Web App.不过,HTML5 Web APP的出现能否在未来取代移动应用,就目前来说,还是个未知数.一方面,用户在使用习惯上,不喜 ...

  4. LAMP环境搭建成功后的部分相关配置

    LAMP环境搭建成功后,通常还需要做一些其他配置来完善,本文主要记录常用到的一些设置. 所有的配置是基于Ubuntu 16.04 + Apache2.4 + Mysql5.7 + Php7.0,对于其 ...

  5. Python爬虫之『urlopen』

    本文以爬取百度首页为示例来学习,python版本为python3.6.7,完整代码会在文章末附上 本次学习所用到的python框架:urllib.request 本次学习所用到的函数: urllib. ...

  6. WPF通用框架 数据库结构

    前言 由於技術轉型, 目前大部分工作都是WPF為主, 但是趨於如今想在網絡上找一套能夠滿意的WPF權限管理框架太難, 因為WinForm那時候是有一套改寫過的權限框架, 所以數據庫設計這塊已經有了一個 ...

  7. Kali Linux下安装VMware Tools

    引言 Kali Linux是基于Debian的Linux发行版, 设计用于数字取证和渗透測试.安装Kali Linux非常easy,可是安装VMware Tools的过程就有点麻烦了,由于在安装中途会 ...

  8. codeforces 204E. Little Elephant and Strings(广义后缀自动机,Parent树)

    传送门在这里. 大意: 给一堆字符串,询问每个字符串有多少子串在所有字符串中出现K次以上. 解题思路: 这种子串问题一定要见后缀自动机Parent树Dfs序统计出现次数都是套路了吧. 这道题统计子串个 ...

  9. Django快速搭建博客

    准备工作: 1.Python 2.Django 3.Git 安装Python: 官网下载 安装Django: #安装最新版本的Django $ pip install django #或者指定安装版本 ...

  10. C++ 与C# 对应的变量互转

    一.C++ 与C# 对应的变量互转的使用实例 C++的动态链接库的函数: C# 调用C++动态链接库数据类型的转换,其中在C++中数据类型为char *,在C#中对应的数据类型为intPtr. 二.常 ...