The company has n machine, every machine has a maximum working hours and a level, if a task time exceeding the maximum working hours of the computer, the computer will not be able to complete this task, each machine a day can complete a task, each task can only be done by a machine,
The company hopes to maximize the number they can complete the task of today, if there are multiple solutions, they want to make money, to the greatest extent
Input format:
The input contains several test cases,
The first line contains two integers N and M.N is machine number. M is the number of tasks (1 & lt;=N & lt;=100000, 1 & lt;=M & lt;=100000),
The following N lines each line contains two integer xi (0 & lt; Xi & lt; 1440), yi (0=& lt; Yi & lt;=100). Xi is the maximum time machine can work. Yi is machine level,
The next M lines each line contains two integer xi (0 & lt; Xi & lt; 1440), yi (0=& lt; Yi & lt;=100). Xi is the time needed to complete the task. Yi is a task level,
The output format:
For each test case, the output two integers, the company to the maximum number of tasks can be finished today and will receive the money,
# include & lt; Iostream>
# include
using namespace std;
Struct node
{
Int x, y;
} [100005] s1 and s2 [100005].
Int CMP (node a, node b)
{
If (a.x==b.x)
Return a.y & gt; B.y.
Return a.x & gt; B.x;
}
Int main () {
Int n, m, I, j, num, l, q, t, p;
Long long money;
Cin> N> m;
for(i=0; i
}
for(i=0; i
}
Sort (s1, s1 + n, CMP);
Sort (s2, s2 + m, CMP);
Money=0;
For (I=0; i
P=s1 [j]. J y;
Q=j;
}
}
If (t> 0 {
[q]. S1 x=0;
[q]. S1 y=0;
t=0;
P=0;
Money=500 * s2 [I]. X + 2 * s2 [I] y + money;
num++;
}
}
cout
Why does a test by not,