日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【CodeForces - 485B】Valuable Resources (贪心,水题,几何相关)

發布時間:2023/12/10 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【CodeForces - 485B】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.

Examples

Input

2 0 0 2 2

Output

4

Input

2 0 0 0 3

Output

9

題目大意:

給定一些點,要用盡量小的正方形框住所有的點,輸出矩形的大小。

解題報告:

? ?這題主要就是讀題的時候沒注意那個“正方形”,直到看到樣例,,其實題目中說的很清楚“Let's suppose that your task is to build a square city. ”。。。英文不及格好吧、、

AC代碼:

#include<cstdio> #include<iostream> #include<algorithm> #include<queue> #include<map> #include<vector> #include<set> #include<string> #include<cmath> #include<cstring> #define ll long long #define pb push_back #define pm make_pair using namespace std; const int MAX = 2e5 + 5; int n,x,y,a[MAX],ans; const ll INF = 0x3f3f3f3f3f; int main() {ll n,x,y,minx = INF,miny = INF,maxx = -INF,maxy = -INF;cin>>n;while(n--) {scanf("%lld%lld",&x,&y);minx = min(minx,x); maxx = max(maxx,x);miny = min(miny,y); maxy = max(maxy,y);} ll tmp = max((maxx-minx),(maxy-miny));printf("%lld\n", tmp*tmp);return 0; }

?

總結

以上是生活随笔為你收集整理的【CodeForces - 485B】Valuable Resources (贪心,水题,几何相关)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。