#P10464. Task

Task

题目描述

Today the company has mm tasks to complete. The ii-th task need xix_i minutes to complete. Meanwhile, this task has a difficulty level yiy_i. The machine whose level below this task’s level yiy_i cannot complete this task. If the company completes this task, they will get (500×xi+2×yi)(500\times x_i+2\times y_i) dollars.

The company has nn machines. Each machine has a maximum working time and a level. If the time for the task is more than the maximum working time of the machine, the machine can not complete this task. Each machine can only complete a task one day. Each task can only be completed by one machine.

The company hopes to maximize the number of the tasks which they can complete today. If there are multiple solutions, they hopes to make the money maximum.

输入格式

The input contains several test cases.

The first line contains two integers NN and MM. NN is the number of the machines.M is the number of tasks (1N100000,1M100000)(1 \leq N \leq 100000, 1\leq M\leq 100000).

The following NN lines each contains two integers xi(0<xi<1440),yi(0yi100)x_i(0<x_i<1440),y_i(0\leq yi\leq 100). xix_i is the maximum time the machine can work. yiy_i is the level of the machine.

The following MM lines each contains two integers xi(0<xi<1440),yi(0yi100)x_i(0<x_i<1440),y_i(0\leq y_i\leq 100). xix_i is the time we need to complete the task. yiy_i is the level of the task.

输出格式

For each test case, output two integers, the maximum number of the tasks which the company can complete today and the money they will get.

1 2 
100 3 
100 2 
100 1
1 50004