Cod sursa(job #1635172)

Utilizator ancabdBadiu Anca ancabd Data 6 martie 2016 15:15:09
Problema Pachete Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.98 kb
#include <fstream>
#include <algorithm>

using namespace std;

ifstream fin ("pachete.in");
ofstream fout ("pachete.out");

struct livrare
{
    long long x, y;
    int ok;
} A[50001], st;
int n, nrdr;

bool cmp(livrare const a, livrare const b)
{
    if (a.x > b.x)return true;
    else if (a.x == b.x && a.y > b.y)return true;
    return false;
}
bool intre(int b, int c, int nr)
{
    if (b >= nr && c<=nr)return true;
    else if (b <=nr && c >= nr)return true;
    return false;
}
int main()
{
    fin >> n >> st.x >> st.y;
    for (int i=1; i<=n; i++)fin >> A[i].x >> A[i].y;
    nrdr=n;
    sort(A+1, A+1+n, cmp);

    for (int i=1; i<=n; i++)
        for (int j=1; j<=n; j++)
        {
            if (intre(A[i].x, st.x, A[j].x) == true && intre(A[i].y, st.y, A[j].y) == true && A[j].ok==0 && j != i)
            {
                nrdr--;
                A[j].ok=1;
                j = n+1;
            }
        }
    fout << nrdr;
    return 0;
}