B. 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

这道题又被玩了,用int各种超范围。。。以后要注意啦。。。

题目很简单,CF竟然把A,B题颠倒,别有用心啊。就是让你求能把所有点放在一个正方形里,这个正方形边平行x轴y轴

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std; long long INF = 1E9 + ;
typedef long long LL;
///又被玩了。。。
int main()
{
int n;
LL x, y; while(scanf("%d", &n) != EOF)
{
LL min_x = INF, min_y = INF, max_x = -INF, max_y = -INF;
for(int i = ; i < n; ++i)
{
cin >> x >> y;
min_x = min(min_x, x);
min_y = min(min_y, y);
max_y = max(max_y, y);
max_x = max(max_x, x);
}
LL xx = max_x - min_x;
LL yy = max_y - min_y;
LL dis = (xx > yy) ? xx : yy;
cout << dis * dis <<endl;
}
return ;
}

CodeForceS#276-B(求最大值)的更多相关文章

  1. HDU 1754 I Hate It 线段树单点更新求最大值

    题目链接 线段树入门题,线段树单点更新求最大值问题. #include <iostream> #include <cstdio> #include <cmath> ...

  2. HDU 2795 Billboard(区间求最大值的位置update的操作在query里做了)

    Billboard 通过这题,我知道了要活用线段树的思想,而不是拘泥于形式, 就比如这题 显然更新和查询放在一起很简单 但如果分开写 那么我觉得难度会大大增加 [题目链接]Billboard [题目类 ...

  3. c# 任意多个数,求最大值

    c#  任意多个数,求最大值 使用parms: 正在研究中,如果有好的方案,可评论,共同进步,共同提高,谢谢!

  4. 【c语言】求最大值

    一.我个人觉得求最大值比较简单的一种方法(当然同时求最大值和最小值时稍微改改也能行) #include <stdio.h> int main(void) { int f, i, max; ...

  5. zzuli求最大值

    1786: 求最大值 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 134  Solved: 28SubmitStatusWeb Board Desc ...

  6. POJ 3264 Balanced Lineup【线段树区间查询求最大值和最小值】

    Balanced Lineup Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 53703   Accepted: 25237 ...

  7. js求最大值最小值

    比较数组中数值的大小是比较常见的操作,比较大小的方法有多种,比如可以使用自带的sort()函数,代码如下: <html> <head> <meta charset=&qu ...

  8. java求最大值以及定义方法调用

    class ArrayDome { public static void main(String[] args) { int[] arr = {-12,-51,-12,-11}; int max = ...

  9. 算法笔记_096:蓝桥杯练习 算法提高 求最大值(Java)

    目录 1 问题描述 2 解决方案   1 问题描述 问题描述 给n个有序整数对ai bi,你需要选择一些整数对 使得所有你选定的数的ai+bi的和最大.并且要求你选定的数对的ai之和非负,bi之和非负 ...

  10. elasticsearch聚合案例--分组、求最大值再求最大值的均值

    一.需求 A.B.C代表3个用户,第二列代表各自的得分,求A.B.C的最好成绩以及A.B.C最好成绩的均值 A 10 A 11 A 13 B 11 B 11 B 12 C 10 C 10 C 11 C ...

随机推荐

  1. Linux将Shelll输出写入到文件

    &>  以覆盖的方式,写入文件 &>> 将输出追加到文件 将命令的正确输出与错误输出都放入文件. /dev/null,垃圾箱. 将无用输出放入垃圾箱. 命令>& ...

  2. WebKit示例解读

    如果你曾经在你的App中使用UIWebView加载网页内容的话,你应该体会到了它的诸多不尽人意之处.UIWebView是基于移动版的Safari的,所以它的性能表现十分有限.特别是在对几乎每个Web应 ...

  3. hdu 2087剪花布条

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2087 思路:正常KMP求解aaaaaa  aa得到的结果是6,这题是3.仅仅改一点代码就行 当匹配完之 ...

  4. Mac系统下使用VirtualBox虚拟机安装win7--第四步 安装虚拟机硬件扩展包支持

    如 果想要在虚拟机上使用连接在 Mac 上的硬件外设,比如 U 盘,iPhone 等,需要我们在 Virtual Box 官网下载一个硬件支持扩展安装包.同样地,我们先打开虚拟机的下载页面: http ...

  5. MVC – 14.ajax异步请求

    14.1.配置文件 14.2.AjaxHelper – 异步链接按钮 14.3.AjaxHelper – 异步表单 AjaxOptions常见属性: 14.4.AjaxOptions对象生成[对应]触 ...

  6. C#的反射机制

    using System; using System.Collections; using System.Collections.Generic; using System.IO; using Sys ...

  7. c++ 调用dll

    1.首先写一个dll程序并且输出成dll. 新建win32项目,然后在应用程序类型中选择dll. HelloDll.h: #pragma once #ifndef MYDLL_API_EXPORTS ...

  8. 在 Android Studio中恢复已经被移除的Module

    假设名为app的Module已经被移除,则他的图标上小手机图标将会消失.此时如下图编辑settings.gradle,然后点击如图按钮Sync Project with Gradle Files即可. ...

  9. 自己制作QQ空间音乐的具体方法

    1.打开QQ邮箱找到左栏下方的“文件中转站”--点击收藏文件--上传到收藏  将MP3或WMA音乐文件上传 上传完成点下载 下图:   2.点“保存”将最上面一排的地址全部复制  下图   3.为了更 ...

  10. C语言面试

    最全的C语言试题总结 第一部分:基本概念及其它问答题 1.关键字static的作用是什么? 这个简单的问题很少有人能回答完全.在C语言中,关键字static有三个明显的作用: 1). 在函数体,一个被 ...