Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: PitsineeN
Problemset: กางเต็นท์
Language: cpp
Time: 0.163 second
Submitted On: 2026-06-19 15:59:52
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
map<int,int>x_up_min;
map<int,int>x_up_max;
map<int,int>x_down_min;
map<int,int>x_down_max;
int ans=0;
int main(){
int n;
cin>>n;
while(n--){
int x;
int y;
cin>>x>>y;
x_up_max[x-y] = max(x_up_max[x-y],x);
x_down_max[x+y] = max(x_down_max[x+y],x);
if(x_up_min.count(x-y) == 0){//เจอmapครั้งแรก mapครั้งแรกปกติมันจะมีค่าเริิ่มต้นเป็น0
x_up_min[x-y] = x;
}
else{
x_up_min[x-y] = min(x_up_min[x-y] ,x);
}
if(x_down_min.count(x+y) == 0){
x_down_min[x+y]=x;
}
else{
x_down_min[x+y]=min(x_down_min[x+y],x);
}
}
for(auto temp1:x_up_min){
int temp2=abs(temp1.second-x_up_max[temp1.first]);
ans=max(ans,temp2);
}
for(auto temp1:x_down_min){
int temp2=abs(temp1.second-x_down_max[temp1.first]);
ans=max(ans,temp2);
}
cout<<ans;
}