Cod sursa(job #3347891)

Utilizator Andrei-Dani-10Pisla Andrei Daniel Andrei-Dani-10 Data 18 martie 2026 19:08:11
Problema Cadrane Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.01 kb
#include <fstream>

#include <utility>
#define x first
#define y second

#include <algorithm>

using namespace std;

ifstream in("cadrane.in");
ofstream out("cadrane.out");

/** (<=, <=) & (>=, >=) countt **/
/** qwerty - vertical line (aka. x boundd) **/
typedef pair <int, int> pii;
const int nmax = 1e5, maxint = (1 << 30);
int n, maxpoints; pii a[nmax + 2];

int getminpoints(int xx){
    int minpoints = maxint;

    for(int i = 1, score; i <= n; i++){

        pii py = make_pair(xx, a[i].y); score = 0;

        for(int j = 1; j <= n; j++){
            score += ((a[j].x <= py.x && a[j].y <= py.y) ||
                      (a[j].x >= py.x && a[j].y >= py.y));
        }

        minpoints = min(minpoints, score);
    }

    return minpoints;
}

int main(){

    in>>n;
    for(int i = 1; i <= n; i++){
        in>>a[i].x>>a[i].y;
    }

    for(int i = 1; i <= n; i++){
        maxpoints = max(maxpoints, getminpoints(a[i].x));
    }

    out<<maxpoints<<"\n";

    return 0;
}