zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    24.Azkaban调度脚本的编写
    Docker 安装 Apache
    Docker 安装 MongoDB
    Docker 安装 Redis
    Docker 安装 Python
    Docker 安装 Tomcat
    Docker 安装 MySQL
    Docker 安装 PHP
    Docker 安装 Nginx
    Docker 镜像使用
  • 原文地址:https://www.cnblogs.com/Enumz/p/4078450.html
Copyright © 2011-2022 走看看