Valuable Resources

Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems.
Let's suppose that your task is to build a square city. The world map uses the Cartesian coordinates. The sides of the city should be parallel to coordinate axes. The map contains mines with valuable resources, located at some points with integer coordinates. The sizes of mines are relatively small, i.e. they can be treated as points. The city should be built in such a way that all the mines are inside or on the border of the city square.
Building a city takes large amount of money depending on the size of the city, so you have to build the city with the minimum area. Given the positions of the mines find the minimum possible area of the city.
Input
The first line of the input contains number n — the number of mines on the map (2 ≤ n ≤ 1000). Each of the next n lines contains a pair of integers xi and yi — the coordinates of the corresponding mine ( - 109 ≤ xi, yi ≤ 109). All points are pairwise distinct.
Output
Print the minimum area of the city that can cover all the mines with valuable resources.
Sample test(s)
Input
2
0 0
2 2
Output
4
Input
2
0 0
0 3
Output
9

题目大意:

    给定一些资源点坐标,建立一个正方形且平行于坐标轴的村庄,包含所有的资源点。

解题思路:

    比上个题简单。直接做就ok。

Code:

 /*************************************************************************
> File Name: CF485B.cpp
> Author: Enumz
> Mail: 369372123@qq.com
> Created Time: 2014年11月06日 星期四 01时17分03秒
************************************************************************/ #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<climits>
#define MAXN 100000
#define LL long long
using namespace std;
int main()
{
LL max_x,min_x,max_y,min_y;
min_x=min_y=INT_MAX;
max_x=max_y=INT_MIN;
int T;
cin>>T;
while (T--)
{
int tmpx,tmpy;
cin>>tmpx>>tmpy;
if (tmpx>max_x) max_x=tmpx;
if (tmpx<min_x) min_x=tmpx;
if (tmpy>max_y) max_y=tmpy;
if (tmpy<min_y) min_y=tmpy;
}
LL Max=max(max_y-min_y,max_x-min_x);
cout<<Max*Max<<endl;
return ;
}

CodeForces485B——Valuable Resources(水题)的更多相关文章

  1. HDU 5889 Barricade(最短路+最小割水题)

    Barricade Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total ...

  2. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  3. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  4. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  5. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  6. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

  7. BZOJ 1303 CQOI2009 中位数图 水题

    1303: [CQOI2009]中位数图 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2340  Solved: 1464[Submit][Statu ...

  8. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  9. ACM水题

    ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...

随机推荐

  1. JQuery 对 Select option 的操作---转载

    <select id="selectID" > <option value="1">1</option> <optio ...

  2. Abstract Class与 Interface 的区别

    表格                                                                                               Abs ...

  3. 命令学习:iftop

    iftop显示带宽使用情况 http://riobard.com/2010/04/30/l2tp-over-ipsec-ubuntu/ http://jaseywang.me/2011/12/19/i ...

  4. vs2012 condition_variable notify_one 崩溃

    vs2012项目中用到 condition_variable系统方法,程序运行过程过程中偶尔出现notify_one崩溃, 程序运行的服务器系统版本是windows server 2008 R2 SP ...

  5. 小技巧---查doc文档的index.html怎么用的和chm一样

    看包里面是否有E:\Java\hibernate3.3.2\hibernate-annotations-3.4.0.GA\hibernate-annotations-3.4.0.GA\doc\refe ...

  6. JAVA Hashmap不能用基本的数据类型

    今天开始学习Java... 转载:http://moto0421.iteye.com/blog/1143777 今天试了一下HahsMap, 采用如下形似定义 (这个下面是用了csdn的一位同仁的文章 ...

  7. google大赛 入围赛250分真题

    Problem StatementYou have a collection of music files with names formatted as "genre-artist-alb ...

  8. .NET设计模式(7):创建型模式专题总结(Creational Pattern)(转)

    概述 创建型模式,就是用来创建对象的模式,抽象了实例化的过程.它帮助一个系统独立于如何创建.组合和表示它的那些对象.本文对五种常用创建型模式进行了比较,通过一个游戏开发场景的例子来说该如何使用创建型模 ...

  9. uiwebview和 js交互框架

    WebViewJavascriptBridge

  10. ssh 远程 centos 乱码

    今天,帮我们同学处理一下中文显示乱码的问题.这个是个国内Linux用户烦恼的问题,由于大部分的Linux发行版都是以英语为主体的,而且英文在通用性和稳定性上都比中文要好一些,各种奇怪的BUG也要少一点 ...