Apple Catching
시간 제한2초메모리 제한1024 MB
소들이 수직선 위에 도착해 초속 1로 움직여 사과 하나씩을 잡을 수 있을 때, 잡을 수 있는 사과 수의 최댓값을 구합니다.
문제
It's raining apples! At certain points in time, some number of apples will hit the number line. At certain points in time, some of Farmer John's cows will arrive on the number line and start catching apples.
If an apple hits the number line without a cow to catch it, it is lost forever. If a cow and an apple arrive at the same time, the cow catches it. Each cow can travel one unit per second. Once a cow catches a single apple, she exits the number line.
If FJ's cows collaborate optimally, how many apples can they catch in total?
입력
The first line contains (), the number of times apples hit the number line or FJ's cows appear.
The next lines each contain four integers , , , and ().
- If , this means that of FJ's cows arrive on the number line at time at location .
- If , this means that apples will hit the number line at time at location .
It is guaranteed that all of the ordered pairs are distinct.
출력
The maximum number of apples FJ's cows may collectively catch.