#include #include #include using namespace std; struct node { int x,y; } s1[100005],s2[100005]; int cmp(node a,node b) { if(a.x == b.x) return a.y>b.y; return a.x>b.x; } int main() { int n,m,i,j,cnt; __int64 sum; while(~scanf("%d%d",&n,&m)) { for(i = 0; i=s2[i].x) { c[s1[j].y]++; j++; } for(int k = s2[i].y; k<=100; k++) { if(c[k]) { c[k]--; sum+=(s2[i].x*500+s2[i].y*2); cnt++; break; } } } printf("%d %I64d\n",cnt,sum); } }