#include<bits/stdc++.h>
using namespace std;
const int M=100010;
struct node{
int x,y;
}a[M],b[M];
int p[110];
int cmp(node q,node p){
if(q.x!=p.x)return q.x>p.x;
return q.y>p.y;
}
int main(){
int n,m,i,j,k,s;
long long ans;
while(scanf("%d%d",&n,&m)!=EOF){
memset(p,0,sizeof(p));
for(i=1;i<=n;i++)
scanf("%d%d",&a[i].x,&a[i].y);
for(i=1;i<=m;i++)
scanf("%d%d",&b[i].x,&b[i].y);
sort(a+1,a+1+n,cmp);
sort(b+1,b+1+m,cmp);
ans=s=0;
k=1;
for(i=1;i<=m;i++){
while(a[k].x>=b[i].x&&k<=n){
p[a[k].y]++;
k++;
}
for(j=b[i].y;j<=100;j++){
if(p[j]){
p[j]--;
s++;
ans+=b[i].x*500+b[i].y*2;
break;
}
}
}
printf("%d %lld\n",s,ans);
}
return 0;
}
HDU 4864 Task
最新推荐文章于 2021-04-13 13:16:59 发布