Horns and Hooves

면접 대비

시간 제한2초메모리 제한1024 MB

요약
뿔과 발굽의 모든 짝에서 뿔의 가격이 더 큰 경우, 같은 경우, 더 작은 경우의 개수를 각각 센다.
난이도

보통10점 중 5점

유형
정렬, 투 포인터, 배열, 누적 합
정답자
아직 제출이 없습니다

문제

The attempted assault on Koreyko, a secret millionaire, was a disastrous failure. The foster brothers Panikovskiy and Balaganov have barricaded themselves in their office. They are playing a strange game. One of them has a room full of horns, and the other has a room full of hooves. They are taking all possible pairs (horn, hoof), and whoever has more expensive object in the pair wins. They want to know one thing --- who will win more often. Their psychological integrity has been somewhat compromised and it might be beyond their powers at the moment to solve this problem by their own efforts. Please help them, and they will thank you... with horns and hooves.

입력

The first line of the input file contains two integers nn and mm, where nn is the number of horn types and mm is the number of hoof types (1≤n,m≤1051 \le n, m \le 10^5).

The following nn lines contain descriptions of horns, one type per line. Each type is defined by two positive integers; the first integer is the cost of one horn of the given type and the second integer is the supply of horns of this type (the number of individual units).

The following mm lines contain descriptions of hoof types in the same format.

The cost of any horn or hoof does not exceed 10910^9.

The number of horns and hooves of each type is not greater than 10410^4.

출력

The output file must contain three numbers -- the number of pairs where the price of horn is greater, equal or less than the price of hoof, respectively.

예제1

  1. 예제 1

    입력
    3 2
    1 2
    2 3
    4 1
    2 3
    3 1
    
    예상 출력
    4 9 11