Cod sursa(job #3232609)

Utilizator elbarosPetre Tudor elbaros Data 31 mai 2024 11:02:45
Problema Pachete Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.35 kb
#include <set>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;

int n;
int64_t xb, yb;
vector<pair<int64_t, int64_t> > v;

int count(vector<pair<int64_t, int64_t> >& vec) {
    int res = 0;

    sort(vec.begin(), vec.end());
    set<int64_t> ys;
    for (auto const& [_, y]: vec) {
        auto it = ys.lower_bound(y);
        if (it == ys.begin()) {
            res++;
            ys.insert(y);
        } else {
            --it;
            ys.erase(it);
            ys.insert(y);
        }
    }
    return res;
}

int main() {
    ifstream in("pachete.in");
    ofstream out("pachete.out");

    in >> n >> xb >> yb;
    for (int i = 0; i < n; i++) {
        int64_t x, y;
        in >> x >> y;
        v.emplace_back(x, y);
    }

    vector<pair<int64_t, int64_t> > qdr1;
    vector<pair<int64_t, int64_t> > qdr2;
    vector<pair<int64_t, int64_t> > qdr3;
    vector<pair<int64_t, int64_t> > qdr4;
    for (auto [x, y] : v) {
        if (x > xb && y > yb) {
            qdr1.emplace_back(x, y);
        } else if (x > xb && y < yb) {
            qdr2.emplace_back(x, yb + yb - y);
        } else if (x < xb && y < yb) {
            qdr3.emplace_back(2 * xb - x, 2 * yb - y);
        } else {
            qdr4.emplace_back(2 * xb - x, y);
        }
    }

    out << count(qdr1) + count(qdr2) + count(qdr3) + count(qdr4) << "\n";
    return 0;
}