CodeForces485B——Valuable Resources(水题)

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:

 1 /*************************************************************************
 2     > File Name: CF485B.cpp
 3     > Author: Enumz
 4     > Mail: 369372123@qq.com
 5     > Created Time: 2014年11月06日 星期四 01时17分03秒
 6  ************************************************************************/
 7 
 8 #include<iostream>
 9 #include<cstdio>
10 #include<cstdlib>
11 #include<string>
12 #include<cstring>
13 #include<list>
14 #include<queue>
15 #include<stack>
16 #include<map>
17 #include<set>
18 #include<algorithm>
19 #include<cmath>
20 #include<bitset>
21 #include<climits>
22 #define MAXN 100000
23 #define LL long long
24 using namespace std;
25 int main()
26 {
27     LL max_x,min_x,max_y,min_y;
28     min_x=min_y=INT_MAX;
29     max_x=max_y=INT_MIN;
30     int T;
31     cin>>T;
32     while (T--)
33     {
34         int tmpx,tmpy;
35         cin>>tmpx>>tmpy;
36         if (tmpx>max_x) max_x=tmpx;
37         if (tmpx<min_x) min_x=tmpx;
38         if (tmpy>max_y) max_y=tmpy;
39         if (tmpy<min_y) min_y=tmpy;
40     }
41     LL Max=max(max_y-min_y,max_x-min_x);
42     cout<<Max*Max<<endl;
43     return 0;
44 }

 

转载于:https://www.cnblogs.com/Enumz/p/4078450.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值