标签:des style blog http color os
1 2 100 3 100 2 100 1
1 50004
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
int n,m;
int h[maxn];
struct node{
int x,y;
}e[maxn],f[maxn];
int cmp(node l1,node l2)
{
if(l1.x==l2.x)
return l1.y>l2.y;
return l1.x>l2.x;
}
int main()
{
while(~scanf("%d%d",&n,&m))
{
memset(h,0,sizeof(h));
for(int i=0;i<n;i++)
scanf("%d%d",&e[i].x,&e[i].y);
for(int i=0;i<m;i++)
scanf("%d%d",&f[i].x,&f[i].y);
sort(e,e+n,cmp);
sort(f,f+m,cmp);
int num=0,j=0;
long long ans=0;
for(int i=0;i<m;i++)
{
while(j<n&&e[j].x>=f[i].x)//由于对e,f,都排了序所以找出大于f[i].x所有的e[j],将e[j].y储存起来;
{
h[e[j].y]++;
j++;
}
for(int k=f[i].y;k<=100;k++)//从找到的e[j].y中选择最小的
{
if(h[k])//判断是否存在
{
h[k]--;
num++;
ans+=f[i].x*500+f[i].y*2;
break;
}
}
}
printf("%d %I64d\n",num,ans);
}
return 0;
}
HDU 4864(多校)1004 Task,布布扣,bubuko.com
标签:des style blog http color os
原文地址:http://blog.csdn.net/u013582254/article/details/38050931