Submission

Status:
PPPPP-TTTT

Score: 50

User: ShynyC

Problemset: กางเต็นท์

Language: cpp

Time: 1.092 second

Submitted On: 2025-04-19 21:12:09

#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

int main(){
    int n,a,b,maxnum = INT_MIN,max = 0;
    pair<int,int> locations;
    vector<pair<int,int> > vec;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        if(a > maxnum){
            maxnum = a;
        }
        if(b > maxnum){
            maxnum = b;
        }
        locations.first = a;
        locations.second = b;
        vec.push_back(locations);
    }
    sort(vec.begin(),vec.end());
    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            if(i != j){
                for(int k = max; k+i < maxnum; k++){
                    if(vec[i].first+k == vec[j].first && vec[i].second+k == vec[j].second){
                        max = k;
                        //cout << vec[i].first << " " << vec[i].second << "\n";
                    }else if(vec[i].first+k == vec[j].first && vec[i].second-k == vec[j].second){
                        max = k;
                        //cout << vec[i].first << " " << vec[i].second << "\n";
                    }
                }
            }
        }
    }
    cout << max;
}