Submission #16705345


Source Code Expand

// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 1e9+1;
//
//
bool oper(const pair<ll, ll>& fst, const pair<ll, ll>& snd){
    return (fst.first + fst.second) < (snd.first + snd.second);
}
void solve(){
    ll n;
    cin>>n;
    vector<pair<ll, ll>> vec(n);
    for(int i = 0; i < n; i++)
        cin>>vec[i].first>>vec[i].second;
    sort(vec.begin(), vec.end(), oper);
    ll ans = 0;
    pair<ll, ll> fst = vec[0], snd = vec[n-1];
    ans = max(ans, abs(snd.first - fst.first) + abs(snd.second - fst.second));
    // cout<<ans;
    for(int i = 0; i < n; i++)
        vec[i].second = MAX - vec[i].second;
    sort(vec.begin(), vec.end(), oper);
    fst = vec[0], snd = vec[n-1];
    ans = max(ans, abs(snd.first - fst.first) + abs(snd.second - fst.second));
    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Submission Info

Submission Time
Task E - Dist Max
User shivam51
Language C++ (GCC 9.2.1)
Score 500
Code Size 1189 Byte
Status AC
Exec Time 90 ms
Memory 6360 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 18
Set Name Test Cases
Sample sample00, sample01
All handmade02, handmade03, handmade04, handmade05, handmade06, handmade07, handmade08, handmade09, random07, random08, random09, random10, random11, random12, random13, random14, sample00, sample01
Case Name Status Exec Time Memory
handmade02 AC 8 ms 3504 KiB
handmade03 AC 2 ms 3572 KiB
handmade04 AC 2 ms 3580 KiB
handmade05 AC 61 ms 6268 KiB
handmade06 AC 58 ms 6296 KiB
handmade07 AC 72 ms 6308 KiB
handmade08 AC 71 ms 6264 KiB
handmade09 AC 74 ms 6360 KiB
random07 AC 90 ms 6308 KiB
random08 AC 85 ms 6272 KiB
random09 AC 86 ms 6268 KiB
random10 AC 87 ms 6296 KiB
random11 AC 87 ms 6328 KiB
random12 AC 87 ms 6312 KiB
random13 AC 84 ms 6268 KiB
random14 AC 57 ms 5156 KiB
sample00 AC 3 ms 3572 KiB
sample01 AC 2 ms 3600 KiB