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

【题意】

让你找到一个各边和坐标轴平行的矩形。使得这个矩形包含至少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. js---05 自定义属性

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  2. webgoat7.1开发版环境搭建

    环境准备:git mavenjdktomcat然后进入正文:下载webgoat门户cd ~/webgoatgit clone https://github.com/WebGoat/WebGoat.gi ...

  3. Resize图片

    在网站上传图片的时候,提示图片太大了. 有5种方式来调整图片大小 http://www.wikihow.com/Resize-a-JPEG picresize.com 这个网站比较靠谱:使用Windo ...

  4. android图像处理系列之三-- 图片色调饱和度、色相、亮度处理

    原图: 处理后: 下面贴代码: 一.图片处理层: package com.jacp.tone.view; import java.util.ArrayList; import android.cont ...

  5. hdoj 2122 Ice_cream’s world III【最小生成树】

    Ice_cream's world III Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  6. 从头认识Spring-2.3 注解装配-@autowired(4)-required(1)

    这一章节我们来具体讨论一下@autowired里面的參数required. 1.domain(重点) 蛋糕类: package com.raylee.my_new_spring.my_new_spri ...

  7. 洛谷 P2679 子串

    题目背景 无 题目描述 有两个仅包含小写英文字母的字符串 A 和 B.现在要从字符串 A 中取出 k 个互不重叠的非空子串,然后把这 k 个子串按照其在字符串 A 中出现的顺序依次连接起来得到一 个新 ...

  8. int android.support.v7.widget.RecyclerView$ViewHolder.mItemViewType' on a null.....

    Android.support.v7.widget.RecyclerView$ViewHolder.mItemViewType' on a null..空指针问题,费劲心思才找到报空指针的原因: 代码 ...

  9. linux监测tomcat服务

    原文链接:https://blog.csdn.net/qq_37936542/article/details/81086928 项目上线之后,tomcat服务器有时候会莫名其妙的挂掉,利用shell写 ...

  10. ArcGIS 点要素新增点

    IFeatureLayer layer = FrmMain.m_mapControl.get_Layer(0) as IFeatureLayer; IFeatureClass featureClass ...