Cod sursa(job #2496174)

Utilizator andreitudorpAndrei Tudor Popescu andreitudorp Data 20 noiembrie 2019 12:56:39
Problema Ograzi Scor 20
Compilator cpp-64 Status done
Runda casiaiziscanudaisimulareprimaora Marime 1.01 kb
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

ifstream cin("ograzi.in");
ofstream cout("ograzi.out");

#define MAXN 50005

struct coord
{
    int x;
    int y;
} coords[MAXN];

bool Compare(coord vala, coord valb)
{
    return vala.x < valb.x;
}

int main()
{
    int n, m, w, h;
    int ans = 0;

    cin >> n >> m >> w >> h;

    int x, y;
    for(int i = 0; i < n; i++)
    {
        cin >> coords[i].x >> coords[i].y;
    }

    sort(coords+1, coords+n,  Compare);


    for(int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        for(int i = 0; i < n; i++)
        {
            if(coords[i].x <= x && x <= coords[i].x + w)
            {
                if(coords[i].y <= y && y <= coords[i].y + h)
                {
                    ans++;
                    break;
                }
            }
            if(x  <  coords[i].x)
                break;
        }
    }

    cout << ans;
    return 0;
}