#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

const int MAXN = 1000 * 100 + 10;
ll p[MAXN];
ll b[MAXN];
bool mark[MAXN];
bool markb[MAXN];

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	int n, m, a, a2, ans1 = 0;
	cin >> n >> m >> a;
	a2 = a;
	for(int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	for(int i = 0; i < m; i++)
	{
		cin >> p[i];
	}
	sort(b, b+n);
	sort(p, p+m);
	for(int i = n-1; i >= 0; i--)
	{
		int s = 0, e = m, c = -1;
		while(s < e)
		{
			int mid = (s + e)/2;
			if(mark[mid])
			{
				s++;
			}
			else
			{
				if(p[mid] > b[i])
				{
					e = mid;
				}
				else
				{
					c = mid;
					s = mid + 1;
				}
			}
		}
		if(c != -1)
		{
			ans1++;
			//cout << b[i] << endl;
			//ans[i] = c;
			mark[c] = true;
			markb[i] = true;
		}
	}
//	cout << ans1 << endl;
	int ptr = 0;
	while(ptr < m && mark[ptr])
	{
		ptr++;
	}
	reverse(b, b+n);
	reverse(markb, markb + n);
	for(int i = 0; i < n; i++)
	{
		if(!markb[i] && b[i] + a >= p[ptr] && ptr < m)
		{
			a -= (p[ptr] - b[i]);
			mark[ptr] = true;
			//markb[i] = true;
			ans1++;
		//	cout << ptr << endl;
			ptr++;
			while(ptr < m && mark[ptr])
			{
				ptr++;
			}
		}
	}
	int ans2 = 0;
	for(int i = 0; i < ans1; i++)
	{
		ans2 += p[i];
	}
	cout << ans1 << ' ' << max(ans2 - a2, 0) << endl;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

const int MAXN = 1000 * 100 + 10;
ll ans[MAXN];
ll p[MAXN];
ll b[MAXN];
bool mark[MAXN];
bool markb[MAXN];

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	int n, m, a, a2, ans1 = 0;
	cin >> n >> m >> a;
	a2 = a;
	for(int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	for(int i = 0; i < m; i++)
	{
		cin >> p[i];
	}
	sort(b, b+n);
	sort(p, p+m);
	for(int i = 0; i < n; i++)
	{
		int s = 0, e = m, c = -1;
		while(s < e)
		{
			int mid = (s + e)/2;
			if(mark[mid])
			{
				s++;
			}
			else
			{
				if(p[mid] > b[i])
				{
					e = mid;
				}
				else
				{
					c = mid;
					s = mid + 1;
				}
			}
		}
		if(c != -1)
		{
			ans1++;
			//cout << b[i] << endl;
			ans[i] = c;
			mark[c] = true;
			markb[i] = true;
		}
	}
//	cout << ans1 << endl;
	int ptr = 0;
	while(ptr < m && mark[ptr])
	{
		ptr++;
	}
	for(int i = 0; i < n; i++)
	{
		if(!markb[i] && b[i] + a >= p[ptr] && !mark[ptr] && ptr < m)
		{
			a -= (p[ptr] - b[i]);
			mark[ptr] = true;
			//markb[i] = true;
			ans1++;
		//	cout << ptr << endl;
			ptr++;
			while(ptr < m && mark[ptr])
			{
				ptr++;
			}
		}
	}
	int ans2 = 0;
	for(int i = 0; i < ans1; i++)
	{
		ans2 += p[i];
	}
	cout << ans1 << ' ' << max(ans2 - a2, 0) << endl;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

const int MAXN = 1000 * 100 + 10;
ll p[MAXN];
ll b[MAXN];
bool mark[MAXN];
bool markb[MAXN];

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	int n, m, a;
	cin >> n >> m >> a;
	for(int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	for(int i = 0; i < m; i++)
	{
		cin >> p[i];
	}
	sort(b, b+n);
	sort(p, p+m);
	reverse(b, b+n);
	ll s = 0, e = min(n, m) + 1, ans = 0;
	while(s < e)
	{
		ll mid = (s + e)/2;
		reverse(b, b+mid);
		ll su = 0;
		for(int i = 0; i < mid; i++)
		{
			if(p[i] > b[i])
			{
				su += p[i]-b[i];
			}
		}
		reverse(b, b+mid);
	//	cout << mid << ' ' << su << endl;
		if(su <= a)
		{
			ans = mid;
			s = mid+1;
		}
		else
		{
			e = mid;
		}
	}

	int ans2 = 0;
	for(int i = 0; i < ans; i++)
	{
		ans2 += p[i];
	}

	cout << ans << ' ' << max(0, ans2-a) << endl;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

const int MAXN = 1000 * 100 + 10;
ll p[MAXN];
ll b[MAXN];
bool mark[MAXN];
bool markb[MAXN];

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	int n, m, a;
	cin >> n >> m >> a;
	for(int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	for(int i = 0; i < m; i++)
	{
		cin >> p[i];
	}
	sort(b, b+n);
	sort(p, p+m);
	reverse(b, b+n);
	int s = 0, e = n + 1, ans = 0;
	while(s < e)
	{
		int mid = (s + e)/2;
		reverse(b, b+mid);
		int su = 0;
		for(int i = 0; i < mid; i++)
		{
			if(p[i] > b[i])
			{
				su += p[i]-b[i];
			}
		}
		reverse(b, b+mid);
		//cout << mid << ' ' << su << endl;
		if(su <= a)
		{
			ans = mid;
			s = mid+1;
		}
		else
		{
			e = mid;
		}
	}

	int ans2 = 0;
	for(int i = 0; i < ans; i++)
	{
		ans2 += p[i];
	}

	cout << ans << ' ' << max(0, ans2-a) << endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int check(int mid,int n,int m,int a,int b[],int p[])
{
	int k=n-mid;
	int long long excess=0;
	for(int i=k;i<n;i++)
		excess=excess+max(p[i-k]-b[i],0);

	if(excess>a)
		return 0;
	else
		return 1;

}
int main()
{
	int n,m,a;
	int long long ans=0;
	cin>>n>>m>>a;
	int b[100005];
	int p[100005];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<m;i++)
		cin>>p[i];
	sort(b,b+n);
	sort(p,p+m);
	int low=0;
	int high=min(n,m);
	int mid;
	//printf("%d\n",check(2,n,m,a,b,p) );
	while(high>=low)
	{
		mid=low+(high-low)/2;
		if(check(mid,n,m,a,b,p) && low==high)
			break;
		if(check(mid,n,m,a,b,p))
		low=mid+1;
		else
		high=mid-1;
	}
	for(int i=0;i<high;i++)
		ans+=p[i];
	ans=ans-a;
	if(ans<0)
		ans=0;
	printf("%d %lld\n",high,ans );
}


#include<bits/stdc++.h>
using namespace std;

int check(int mid,int n,int m,int a,int b[],int p[])
{
	int k=n-mid;
	int long long excess=0;
	for(int i=k;i<n;i++)
		excess=excess+max(p[i-k]-b[i],0);

	if(excess>a)
		return 0;
	else
		return 1;

}
int main()
{
	int n,m,a;
	int long long ans=0;
	cin>>n>>m>>a;
	int b[100005];
	int p[100005];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<m;i++)
		cin>>p[i];
	sort(b,b+n);
	sort(p,p+m);
	int low=0;
	int high=min(n,m);
	int mid;
	//printf("%d**\n",check(2,n,m,a,b,p) );
	while(high>=low)
	{
		mid=low+(high-low)/2;
		if(check(mid,n,m,a,b,p) && low==high)
			break;
		if(check(mid,n,m,a,b,p))
		low=mid+1;
		else
		high=mid-1;
	}
	for(int i=0;i<high;i++)
		ans+=p[i];
	ans=ans-a;
	if(ans<0)
		ans=0;
	printf("%d %lld\n",high,ans );
}


#include<bits/stdc++.h>
using namespace std;

int check(int mid,int n,int m,int a,int b[],int p[])
{
	int k=n-mid;
	int excess=0;
	for(int i=k;i<n;i++)
		excess=excess+max(p[i-k]-b[i],0);

	if(excess>a)
		return 0;
	else
		return 1;

}
int main()
{
	int n,m,a;
	int long long ans=0;
	cin>>n>>m>>a;
	int b[100005];
	int p[100005];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<m;i++)
		cin>>p[i];
	sort(b,b+n);
	sort(p,p+m);
	int low=0;
	int high=min(n,m);
	int mid;
	//printf("%d\n",check(2,n,m,a,b,p) );
	while(high>=low)
	{
		mid=low+(high-low)/2;
		if(check(mid,n,m,a,b,p) && low==high)
			break;
		if(check(mid,n,m,a,b,p))
		low=mid+1;
		else
		high=mid-1;
	}
	for(int i=0;i<high;i++)
		ans+=p[i];
	ans=ans-a;
	if(ans<0)
		ans=0;
	printf("%d %lld\n",high,ans );
}


#include<bits/stdc++.h>
using namespace std;

int check(int mid,int n,int m,int a,int b[],int p[])
{
	int k=n-mid;
	int excess=0;
	for(int i=k;i<n;i++)
		excess=excess+max(p[i-k]-b[i],0);

	if(excess>a)
		return 0;
	else
		return 1;

}
int main()
{
	int n,m,a;
	int long ans=0;
	cin>>n>>m>>a;
	int b[100005];
	int p[100005];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<m;i++)
		cin>>p[i];
	sort(b,b+n);
	sort(p,p+m);
	int low=0;
	int high=min(n,m);
	int mid;
	//printf("%d\n",check(2,n,m,a,b,p) );
	while(high>=low)
	{
		mid=low+(high-low)/2;
		if(check(mid,n,m,a,b,p) && low==high)
			break;
		if(check(mid,n,m,a,b,p))
		low=mid+1;
		else
		high=mid-1;
	}
	for(int i=0;i<high;i++)
		ans+=p[i];
	ans=max(ans-a,0);
	printf("%d %ld\n",high,ans );
}


#include<bits/stdc++.h>
using namespace std;

int check(int mid,int n,int m,int a,int b[],int p[])
{
	int k=n-mid;
	int excess=0;
	for(int i=k;i<n;i++)
		excess=excess+max(p[i-k]-b[i],0);

	if(excess>a)
		return 0;
	else
		return 1;

}
int main()
{
	int n,m,a;
	int long ans=0;
	cin>>n>>m>>a;
	int b[100005];
	int p[100005];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<m;i++)
		cin>>p[i];
	sort(b,b+n);
	sort(p,p+m);
	int low=0;
	int high=min(n,m);
	int mid;
	//printf("%d\n",check(2,n,m,a,b,p) );
	while(high>=low)
	{
		mid=low+(high-low)/2;
		if(check(mid,n,m,a,b,p) && low==high)
			break;
		if(check(mid,n,m,a,b,p))
		low=mid+1;
		else
		high=mid-1;
	}
	for(int i=0;i<high;i++)
		ans+=p[i];
	ans=ans-a;
	printf("%d %ld\n",high,ans );
}


#include<bits/stdc++.h>
using namespace std;

int check(int mid,int n,int m,int a,int b[],int p[])
{
	int k=n-mid;
	int excess=0;
	for(int i=k;i<n;i++)
		excess=excess+max(p[i-k]-b[i],0);

	if(excess>a)
		return 0;
	else
		return 1;

}
int main()
{
	int n,m,a;
	int long ans=0;
	cin>>n>>m>>a;
	int b[100005];
	int p[100005];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<m;i++)
		cin>>p[i];
	sort(b,b+n);
	sort(p,p+m);
	int low=0;
	int high=min(n,m);
	int mid;
	//printf("%d\n",check(2,n,m,a,b,p) );
	while(high>=low)
	{
		mid=low+(high-low)/2;
		if(check(mid,n,m,a,b,p) && low==high)
			break;
		if(check(mid,n,m,a,b,p))
		low=mid+1;
		else
		high=mid-1;
	}
	for(int i=0;i<high;i++)
		ans+=p[i];
	ans=ans-a;
	if(ans<0)
		ans=0;
	printf("%d %ld\n",high,ans );
}


#include <bits/stdc++.h>
using namespace std;
int a[101010];
int b[101010];
int main()
{
    int n,m,t;
    scanf("%d%d%d",&n,&m,&t);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<m;i++)
        scanf("%d",&b[i]);
    sort(a,a+n);
    sort(b,b+m);
    int l=0;
    int r=min(n,m);
    int ans=0;
    long long sum=0;
    while(l<=r)
    {
        sum=0;
        int mid=(l+r)>>1;
        for(int i=0;i<mid;i++)
            if(b[mid-i-1]>a[n-i-1])
                sum+=b[mid-i-1]-a[n-i-1];
        if(sum<=t)
        {
            ans=mid;
            l=mid+1;
        }
        else r=mid-1;
    }
    long long ssum=0;
    for(int i=0;i<ans;i++)
    {
        ssum+=b[i];
    }
    ssum=max(0,ssum-t);
    printf("%d %lld\n",ans,ssum );
}


#include <bits/stdc++.h>
using namespace std;
int a[101010];
int b[101010];
int main()
{
    int n,m,t;
    scanf("%d%d%d",&n,&m,&t);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<m;i++)
        scanf("%d",&b[i]);
    sort(a,a+n);
    sort(b,b+m);
    int l=0;
    int r=min(n,m);
    int ans=0;
    long long sum=0;
    while(l<=r)
    {
        sum=0;
        int mid=(l+r)>>1;
        for(int i=0;i<mid;i++)
            if(b[mid-i-1]>a[n-i-1])
                sum+=b[mid-i-1]-a[n-i-1];
        if(sum<=t)
        {
            ans=mid;
            l=mid+1;
        }
        else r=mid-1;
    }
    long long ssum=0;
    for(int i=0;i<ans;i++)
    {
        ssum+=b[i];
    }
    ssum=max((long long) 0,ssum-t);
    printf("%d %lld\n",ans,ssum );
}


#include <bits/stdc++.h>
using namespace std;
int a[101010];
int b[101010];
int main()
{
    int n,m,t;
    scanf("%d%d%d",&n,&m,&t);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<m;i++)
        scanf("%d",&b[i]);
    sort(a,a+n);
    sort(b,b+m);
    int l=0;
    int r=min(n,m);
    int ans=0;
    long long sum=0;
    while(l<r)
    {
        sum=0;
        int mid=(l+r)>>1;
        for(int i=0;i<mid;i++)
            if(b[mid-i-1]>a[n-i-1])
                sum+=b[mid-i-1]-a[n-i-1];
        if(sum<=t)
        {
            l=mid+1;
        }
        else r=mid;
    }
    ans=r;
     long long ssum=0;
    for(int i=0;i<ans;i++)
    {
        ssum+=b[i];
    }
    ssum=max((long long) 0,ssum-t);
    printf("%d %lld\n",ans,ssum );
}


#include <bits/stdc++.h>
using namespace std;
int a[101010];
int b[101010];
int main()
{
    int n,m,t;
    scanf("%d%d%d",&n,&m,&t);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<m;i++)
        scanf("%d",&b[i]);
    sort(a,a+n);
    sort(b,b+m);
    int l=0;
    int r=min(n,m);
    int ans=0;
    long long sum=0;
    while(l<=r)
    {
        sum=0;
        int mid=(l+r)>>1;
        for(int i=0;i<mid;i++)
            if(b[mid-i-1]>a[n-i-1])
                sum+=b[mid-i-1]-a[n-i-1];
        if(sum<=t)
        {
            ans=mid;
            l=mid+1;
        }
        else r=mid-1;
    }
    long long ssum=0;
    for(int i=0;i<ans;i++)
    {
        ssum+=b[ans-i-1];
    }
    ssum=max(0LL,ssum-t);
    printf("%d %lld\n",ans,ssum );
}


#include <algorithm>
#include <math.h>
#include <stdio.h>
#define pi acos(-1.0)
using namespace std;
const int maxn=1e5+5;
const int inf=1e10+5;
int pre[maxn],p[maxn];
int a,n,m;
bool check(int mid)
{
    int sum=0;
    for(int i=0;i<mid;i++)
    {
        if(p[mid-i-1]>pre[n-i-1]) sum+=p[mid-i-1]-pre[n-i-1];
    }
     if(sum<=a) return 0;
     else return 1;
}

int main()
{
    int k,ans1,ans2,sum=0;
     scanf("%d%d%d",&n,&m,&a);
     for(int i=0;i<n;i++) scanf("%d",&pre[i]);
     for(int i=0;i<m;i++) scanf("%d",&p[i]);
     sort(pre,pre+n);
     sort(p,p+m);
     int l=0,r=min(n,m);
     while(l<=r)
     {
        int mid=(l+r)>>1;
         if(check(mid)) r=mid-1;
         else l=mid+1,ans1=mid;
     }
    for(int i=0;i<r;i++)
    {
        sum+=p[i];
    }
    ans2=sum-a>0?sum-a:0;
    printf("%d %d",ans1,ans2);
    return 0;

}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 100005;
ll a, b[N], p[N];
int n, m;

inline ll func(int k){
	ll tot = 0;
	for(int i = n - k + 1; i <= n; i++){
		if(b[i] < p[i - n + k])tot += p[i - n + k] - b[i];
	}
	return tot;
}

inline ll compute(int k){
	ll tot = 0;
	for(int i = n - k + 1; i <= n; i++){
		tot += p[i - n + k];
	}
	return tot - a;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	cin>>n>>m>>a;
	for(int i = 1; i <= n; i++){
		cin>>b[i];
	}
	for(int i = 1; i <= m; i++){
		cin>>p[i];
	}
	sort(b + 1, b + n + 1);
	sort(p + 1, p + m + 1);
	int lo = 0, hi = min(n, m);
	while(lo < hi){
		int mi = lo + (hi - lo + 1)/2;
		if(func(mi) <= a)lo = mi;
		else hi = mi - 1;
	}
	cout<<lo<<" "<<compute(lo)<<'\n';

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 100005;
ll a, b[N], p[N];
int n, m;

inline ll func(int k){
	ll tot = 0;
	for(int i = n - k + 1; i <= n; i++){
		if(b[i] < p[i - n + k])tot += p[i - n + k] - b[i];
	}
	return tot;
}

inline ll compute(int k){
	ll tot = 0;
	for(int i = n - k + 1; i <= n; i++){
		tot += p[i - n + k];
	}
	return max(0LL, tot - a);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	cin>>n>>m>>a;
	for(int i = 1; i <= n; i++){
		cin>>b[i];
	}
	for(int i = 1; i <= m; i++){
		cin>>p[i];
	}
	sort(b + 1, b + n + 1);
	sort(p + 1, p + m + 1);
	int lo = 0, hi = min(n, m);
	while(lo < hi){
		int mi = lo + (hi - lo + 1)/2;
		if(func(mi) <= a)lo = mi;
		else hi = mi - 1;
	}
	cout<<lo<<" "<<compute(lo)<<'\n';

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 100005;
ll a, b[N], p[N];
int n, m;

inline ll func(int k){
	ll tot = 0;
	map<ll, int> mp;
	for(int i = 1; i <= m; i++){
		mp[p[i]]++;
	}
	for(int i = k; i >= 1; i--){
		auto it = mp.begin();
		ll val = it->first;
		if(val > b[i])tot += val - b[i];
		mp[val]--; if(!mp[val])mp.erase(val);
	}
	return tot;
}

inline ll compute(int k){
	map<ll, int> mp;
	for(int i = 1; i <= m; i++){
		mp[p[i]]++;
	}
	ll cost = 0;
	for(int i = k; i >= 1; i--){
		auto it = mp.begin();
		ll val = it->first;
		cost += val;
		mp[val]--; if(!mp[val])mp.erase(val);
	}
	return max(0LL, cost - a);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	cin>>n>>m>>a;
	for(int i = 1; i <= n; i++){
		cin>>b[i];
	}
	for(int i = 1; i <= m; i++){
		cin>>p[i];
	}
	sort(b + 1, b + n + 1, greater<ll>());
	int lo = 0, hi = n;
	while(lo < hi){
		int mi = lo + (hi - lo + 1)/2;
		if(func(mi) <= a)lo = mi;
		else hi = mi - 1;
	}
	cout<<lo<<" "<<compute(lo)<<'\n';

	return 0;
}


//IaMaNanBord//

#include <bits/stdc++.h>
using namespace std;

//Macro Shorthands
#define F                       first
#define S                       second
#define f(i,n)                  for(ll i=0;i<=n;i++)
#define rf(i,n)                 for(ll i=n;i>=0;i--)
#define Cf(i,a,b)               for(ll i=a;i<=b;i++)
#define Crf(i,b,a)              for(ll i=b;i>=a;i--)
#define endl                    '\n'
#define pb                      push_back
#define mp                      make_pair
// #define z                       ((ll)1e9 + 7 )
#define every(it,x)             for(auto &it:x)
#define SET(it,x)               for(auto &it:x){cin>>it;}
#define ins                     insert
#define INF						((ll)1e18)
#define Test                    ll t; cin>>t; while(t--)
#define all(v)                  v.begin(),v.end()
#define nline                   cout<<endl

//Macro Shorthands
#ifndef ONLINE_JUDGE
    #define revelio(args...)        { string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
    #define revelio(args...)        {}
#endif

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl; err(++it, args...);}

//Data types
typedef long long               ll;
typedef vector<ll>              vll;
typedef vector<string>          vstr;
typedef vector<char>            vchar;
typedef vector<pair<ll,ll> >    vpll;
typedef set<ll>                 sll;
typedef set<string>             sstr;
typedef set<pair<ll,ll> >       spll;
typedef map<ll,ll>              mllll;
typedef map<string,ll>          mstrll;
typedef queue<ll>               qll;

//Functions
// ll powMod(ll x,ll y)            {ll p=1; while(y){if(y%2){p=(p*x)%z;} y/=2; x=(x*x)%z;} return p;}
// ll CpowMod(ll x,ll y, ll w)     {ll p=1; while(y){if(y%2){p=(p*x)%w;} y/=2; x=(x*x)%w;}return p;}
// ll invMod(ll x)                 {return powMod(x,z-2);}
// ll CinvMod(ll x,ll w)           {return CpowMod(x,w-2,w);}
// ll gcd(ll a, ll b)              {return b == 0 ? a : gcd(b, a % b);}
// ll exGcd(ll a,ll b,ll &x, ll &y){if(b==0){y = 0;x = 1;return a;}ll xtmp, ytmp;ll g = exGcd(b,a%b,xtmp,ytmp);
//                                 x=ytmp; y = xtmp - (a/b)*ytmp;return g;}
// vll sub;
// void subSet(ll k,ll n)          {if(k==n+1){every(it,sub)cout<<it<<" ";cout<<endl;}
//                                 else{sub.pb(k);subSet(k+1,n);
//                                 sub.pop_back();subSet(k+1,n);}}

// vll perm; const ll N = (ll)2e6 ;bool isSelected[N];
// void permut(ll n)               {if(perm.size()==n){every(it,perm)cout<<it<<" ";cout<<endl;}
//                                 else{Cf(i,1,n){if(isSelected[i])continue;perm.pb(i);
//                                 isSelected[i]=1;permut(n);perm.pop_back();isSelected[i] =0;}}}

vll a,b;
ll n;
ll check(ll mid){
    ll x = 0;
    ll sum =0;
    Cf(i,mid,n-1){
        sum += max(0LL,b[x]-a[i]);
        x++;
    }
    return sum;
}
void solve(){
    ll m,c;
    cin>>n>>m>>c;
    a = vll(n),b = vll(m);
    SET(it,a);
    SET(it,b);
    sort(all(a),greater<ll>());
    sort(all(b));
    if(n>m){
        a.resize(m);
        n = m;
    }
    else
    b.resize(n);
    sort(all(a));

    ll l = 0, r=n-1;
    while(l<r){
        ll mid = (l+r)/2;
        ll s = check(mid);
        if(s>c){
            l = mid+1;
        }
        else r = mid;
    }
    ll s = check(l);
    if(s>c){
        cout<<"0 0";
        return;
    }
    cout<<n-l;
    ll ans2 = 0;
    f(i,n-1-l){
        ans2+=b[i];
    }
    ans2-=c;
    cout<<" "<<max(0LL,ans2);
}

int main(){
    ios_base::sync_with_stdio(0) ;
    cin.tie(0) ; cout.tie(0) ;
    // cout.precision(20);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	freopen("error.txt","w",stderr);
    #else

    #endif
    solve();
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC<<" Sec\n";
    #endif
    return 0;
}


//IaMaNanBord//

#include <bits/stdc++.h>
using namespace std;

//Macro Shorthands
#define F                       first
#define S                       second
#define f(i,n)                  for(ll i=0;i<=n;i++)
#define rf(i,n)                 for(ll i=n;i>=0;i--)
#define Cf(i,a,b)               for(ll i=a;i<=b;i++)
#define Crf(i,b,a)              for(ll i=b;i>=a;i--)
#define endl                    '\n'
#define pb                      push_back
#define mp                      make_pair
// #define z                       ((ll)1e9 + 7 )
#define every(it,x)             for(auto &it:x)
#define SET(it,x)               for(auto &it:x){cin>>it;}
#define ins                     insert
#define INF						((ll)1e18)
#define Test                    ll t; cin>>t; while(t--)
#define all(v)                  v.begin(),v.end()
#define nline                   cout<<endl

//Macro Shorthands
#ifndef ONLINE_JUDGE
    #define revelio(args...)        { string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
    #define revelio(args...)        {}
#endif

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl; err(++it, args...);}

//Data types
typedef long long               ll;
typedef vector<ll>              vll;
typedef vector<string>          vstr;
typedef vector<char>            vchar;
typedef vector<pair<ll,ll> >    vpll;
typedef set<ll>                 sll;
typedef set<string>             sstr;
typedef set<pair<ll,ll> >       spll;
typedef map<ll,ll>              mllll;
typedef map<string,ll>          mstrll;
typedef queue<ll>               qll;

//Functions
// ll powMod(ll x,ll y)            {ll p=1; while(y){if(y%2){p=(p*x)%z;} y/=2; x=(x*x)%z;} return p;}
// ll CpowMod(ll x,ll y, ll w)     {ll p=1; while(y){if(y%2){p=(p*x)%w;} y/=2; x=(x*x)%w;}return p;}
// ll invMod(ll x)                 {return powMod(x,z-2);}
// ll CinvMod(ll x,ll w)           {return CpowMod(x,w-2,w);}
// ll gcd(ll a, ll b)              {return b == 0 ? a : gcd(b, a % b);}
// ll exGcd(ll a,ll b,ll &x, ll &y){if(b==0){y = 0;x = 1;return a;}ll xtmp, ytmp;ll g = exGcd(b,a%b,xtmp,ytmp);
//                                 x=ytmp; y = xtmp - (a/b)*ytmp;return g;}
// vll sub;
// void subSet(ll k,ll n)          {if(k==n+1){every(it,sub)cout<<it<<" ";cout<<endl;}
//                                 else{sub.pb(k);subSet(k+1,n);
//                                 sub.pop_back();subSet(k+1,n);}}

// vll perm; const ll N = (ll)2e6 ;bool isSelected[N];
// void permut(ll n)               {if(perm.size()==n){every(it,perm)cout<<it<<" ";cout<<endl;}
//                                 else{Cf(i,1,n){if(isSelected[i])continue;perm.pb(i);
//                                 isSelected[i]=1;permut(n);perm.pop_back();isSelected[i] =0;}}}

vll a,b;
ll n;
ll check(ll mid){
    ll x = 0;
    ll sum =0;
    Cf(i,mid,n-1){
        sum += max(0LL,b[x]-a[i]);
        x++;
    }
    return sum;
}
void solve(){
    ll m,c;
    cin>>n>>m>>c;
    a = vll(n),b = vll(m);
    SET(it,a);
    SET(it,b);
    sort(all(a));
    sort(all(b));
    b.resize(n);
    ll l = 0, r=n-1;
    while(l<r){
        ll mid = (l+r)/2;
        ll s = check(mid);
        if(s>c){
            l = mid+1;
        }
        else r = mid;
    }
    cout<<n-l;
    ll s = check(l);
    ll ans2 = 0;
    f(i,n-1-l){
        ans2+=b[i];
    }
    ans2-=c;
    cout<<" "<<ans2;
}

int main(){
    ios_base::sync_with_stdio(0) ;
    cin.tie(0) ; cout.tie(0) ;
    // cout.precision(20);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	freopen("error.txt","w",stderr);
    #else

    #endif
    solve();
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC<<" Sec\n";
    #endif
    return 0;
}


//IaMaNanBord//

#include <bits/stdc++.h>
using namespace std;

//Macro Shorthands
#define F                       first
#define S                       second
#define f(i,n)                  for(ll i=0;i<=n;i++)
#define rf(i,n)                 for(ll i=n;i>=0;i--)
#define Cf(i,a,b)               for(ll i=a;i<=b;i++)
#define Crf(i,b,a)              for(ll i=b;i>=a;i--)
#define endl                    '\n'
#define pb                      push_back
#define mp                      make_pair
// #define z                       ((ll)1e9 + 7 )
#define every(it,x)             for(auto &it:x)
#define SET(it,x)               for(auto &it:x){cin>>it;}
#define ins                     insert
#define INF						((ll)1e18)
#define Test                    ll t; cin>>t; while(t--)
#define all(v)                  v.begin(),v.end()
#define nline                   cout<<endl

//Macro Shorthands
#ifndef ONLINE_JUDGE
    #define revelio(args...)        { string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
    #define revelio(args...)        {}
#endif

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl; err(++it, args...);}

//Data types
typedef long long               ll;
typedef vector<ll>              vll;
typedef vector<string>          vstr;
typedef vector<char>            vchar;
typedef vector<pair<ll,ll> >    vpll;
typedef set<ll>                 sll;
typedef set<string>             sstr;
typedef set<pair<ll,ll> >       spll;
typedef map<ll,ll>              mllll;
typedef map<string,ll>          mstrll;
typedef queue<ll>               qll;

//Functions
// ll powMod(ll x,ll y)            {ll p=1; while(y){if(y%2){p=(p*x)%z;} y/=2; x=(x*x)%z;} return p;}
// ll CpowMod(ll x,ll y, ll w)     {ll p=1; while(y){if(y%2){p=(p*x)%w;} y/=2; x=(x*x)%w;}return p;}
// ll invMod(ll x)                 {return powMod(x,z-2);}
// ll CinvMod(ll x,ll w)           {return CpowMod(x,w-2,w);}
// ll gcd(ll a, ll b)              {return b == 0 ? a : gcd(b, a % b);}
// ll exGcd(ll a,ll b,ll &x, ll &y){if(b==0){y = 0;x = 1;return a;}ll xtmp, ytmp;ll g = exGcd(b,a%b,xtmp,ytmp);
//                                 x=ytmp; y = xtmp - (a/b)*ytmp;return g;}
// vll sub;
// void subSet(ll k,ll n)          {if(k==n+1){every(it,sub)cout<<it<<" ";cout<<endl;}
//                                 else{sub.pb(k);subSet(k+1,n);
//                                 sub.pop_back();subSet(k+1,n);}}

// vll perm; const ll N = (ll)2e6 ;bool isSelected[N];
// void permut(ll n)               {if(perm.size()==n){every(it,perm)cout<<it<<" ";cout<<endl;}
//                                 else{Cf(i,1,n){if(isSelected[i])continue;perm.pb(i);
//                                 isSelected[i]=1;permut(n);perm.pop_back();isSelected[i] =0;}}}

vll a,b;
ll n;
ll check(ll mid){
    ll x = 0;
    ll sum =0;
    Cf(i,mid,n-1){
        sum += max(0LL,b[x]-a[i]);
        x++;
    }
    return sum;
}
void solve(){
    ll m,c;
    cin>>n>>m>>c;
    a = vll(n),b = vll(m);
    SET(it,a);
    SET(it,b);
    sort(all(a),greater<ll>());
    sort(all(b));
    if(n>m){
        a.resize(m);
        n = m;
    }
    else
    b.resize(n);
    sort(all(a));

    ll l = 0, r=n-1;
    while(l<r){
        ll mid = (l+r)/2;
        ll s = check(mid);
        if(s>c){
            l = mid+1;
        }
        else r = mid;
    }
    cout<<n-l;
    ll s = check(l);
    ll ans2 = 0;
    f(i,n-1-l){
        ans2+=b[i];
    }
    ans2-=c;
    cout<<" "<<max(0LL,ans2);
}

int main(){
    ios_base::sync_with_stdio(0) ;
    cin.tie(0) ; cout.tie(0) ;
    // cout.precision(20);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	freopen("error.txt","w",stderr);
    #else

    #endif
    solve();
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC<<" Sec\n";
    #endif
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 5;

int n, m;
long long a[MAXN], b[MAXN], A, res;

long long calc(int x) {
	bool bad = false;
	long long B = A, total = 0;
	for (int i = 0; i < x && !bad; ++i) {
		if (a[n - x + i] < b[i]) {
			B = B - b[i] + a[n - x + i];
			total += a[n - x + i];
			bad |= B < 0;
		}
		else {
			total += b[i];
		}
	}
	if (bad) {
		return -1;
	}
	return total - B;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m >> A;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	sort(a, a + n);
	sort(b, b + m);
	int l = 0, r = min(n, m);
	while (l <= r) {
		int m = (l + r) / 2;
		long long t = calc(m);
		if (t != -1) {
			l = m + 1;
			res = t;
		}
		else {
			r = m - 1;
		}
	}
	cout << r << ' ' << res;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 5;

int n, m;
long long a[MAXN], b[MAXN], A, accum;

long long calc(int x) {
	long long total = 0, diff = 0, B = A;
	for (int i = 0; i < x; ++i) {
		diff += max(0ll, b[x - i - 1] - a[x - i - 1]);
		total += min(a[x - i - 1], b[x - i - 1]);
	}
	B -= diff;
	total -= B;
	return total;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m >> A;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		accum += a[i];
	}
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	sort(a, a + n);
	sort(b, b + m);
	int l = 0, r = min(n, m);
	while (l <= r) {
		int m = (l + r) / 2;
		if (calc(m) <= accum) {
			l = m + 1;
		}
		else {
			r = m - 1;
		}
	}
	cout << r << ' ' << (!r ? 0 : calc(r));
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 5;

int n, m;
long long a[MAXN], b[MAXN], A, accum[MAXN];

long long calc(int x) {
	long long total = 0, diff = 0, B = A;
	for (int i = 0; i < x; ++i) {
		diff += max(0ll, b[x - i - 1] - a[x - i - 1]);
		total += min(a[x - i - 1], b[x - i - 1]);
	}
	B -= diff;
	total -= B;
	return total;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m >> A;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		accum[i + 1] = a[i] + accum[i];
	}
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	sort(a, a + n);
	sort(b, b + m);
	int l = 0, r = min(n, m);
	while (l <= r) {
		int m = (l + r) / 2;
		if (calc(m) <= accum[m]) {
			l = m + 1;
		}
		else {
			r = m - 1;
		}
	}
	cout << r << ' ' << (!r ? 0 : max(0ll, calc(r)));
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 5;

int n, m;
long long a[MAXN], b[MAXN], A, accum;

long long calc(int x) {
	long long total = 0, diff = 0, B = A;
	for (int i = 0; i < x; ++i) {
		diff += max(0ll, b[x - i - 1] - a[x - i - 1]);
		total += a[x - i - 1];
	}
	B -= diff;
	total -= B;
	return total;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m >> A;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		accum += a[i];
	}
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	sort(a, a + n);
	sort(b, b + m);
	int l = 0, r = min(n, m);
	while (l <= r) {
		int m = (l + r) / 2;
		if (calc(m) <= accum) {
			l = m + 1;
		}
		else {
			r = m - 1;
		}
	}
	cout << r << ' ' << (!r ? 0 : calc(r));
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 5;

int n, m;
long long a[MAXN], b[MAXN], A, accum[MAXN];

long long calc(int x) {
	long long total = 0, diff = 0, B = A;
	for (int i = 0; i < x; ++i) {
		diff += max(0ll, b[x - i - 1] - a[x - i - 1]);
		total += min(a[x - i - 1], b[x - i - 1]);
	}
	B -= diff;
	total -= B;
	return total;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m >> A;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	sort(a, a + n);
	sort(b, b + m);
	for (int i = 1; i <= n; ++i) {
		accum[i] = a[i - 1] + accum[i - 1];
	}
	int l = 0, r = min(n, m);
	while (l <= r) {
		int m = (l + r) / 2;
		if (calc(m) <= accum[n] - accum[n - m]) {
			l = m + 1;
		}
		else {
			r = m - 1;
		}
	}
	cout << r << ' ' << (!r ? 0 : max(0ll, calc(r)));
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 5;

int n, m;
long long a[MAXN], b[MAXN], A, res;

bool calc(int x) {
	bool bad = false;
	long long B = A, total = 0;
	for (int i = 0; i < x && !bad; ++i) {
		if (a[n - x + i] < b[i]) {
			B = B - b[i] + a[n - x + i];
			total += a[n - x + i];
			bad |= B < 0;
		}
		else {
			total += b[i];
		}
	}
	res = max(0ll, total - B);
	return !bad;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m >> A;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	sort(a, a + n);
	sort(b, b + m);
	int l = 0, r = min(n, m);
	while (l <= r) {
		int mid = (l + r) / 2;
		if (calc(mid)) {
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}
	calc(r);
	cout << r << ' ' << (!r ? 0 : res);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int ara[1000000];
int price[1000000];

int main()
{
    int n,m,k;
    cin >> n >> m >> k;
    for(int i = 1; i <= n;i++)cin >> ara[i];
    for(int i = 1; i <= m;i++)cin >> price[i];
    sort(ara+1,ara+n+1);
    sort(price+1,price+m+1);
    int cnt = 0;
    int cost = 0;
    int pos = 1;
    for(int i = 1; i <= n;i++){
        if(price[pos] <= ara[i] and pos <= m){
            //cout << i <<  " " << pos << endl;
            cost += price[pos];
            cnt++;pos++;
        }
        else if(price[pos] <= ara[i]+k and pos <= m){
           // cout << ara[i] << " " << price[pos] << endl;
            cost += ara[i];
            cnt++;
            int pp = price[pos]-ara[i];
            k -= pp;
            pos++;
            //cout << "k = " << k << endl;
        }
    }
    //cout << pos << endl;
    cout << cnt << " " << cost-k <<  endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int long long

int a[1200000],b[1000002];

int32_t main()
{
    int n,m,k;
    cin >>  n >> m >> k;
    for(int i = 1; i <= n;i++)cin >> a[i];
    for(int j = 1; j <= m;j++)cin >> b[j];
    sort(a+1,a+1+n,greater<int>());
    sort(b+1,b+1+m);
    int mid,l=1,r=m;
    int ans = 0;
    while(r-l > 2){
        mid =(l+r)/2;
        if(mid > n){r = mid-1;continue;}
        int res = 0;
        for(int i = 1,j = mid; i <= mid,j>0;i++,j--){
            res += max(0ll,b[j]-a[i]);
        }
        if(res <= k){
            ans = mid;
            l = mid+1;
        }
        else r = mid-1;
    }
    for(mid = l; mid <= r;mid++){
        if(mid > n){r = mid-1;break;}
        int res = 0;
        for(int i = 1,j = mid; i <= mid,j>0;i++,j--){
            res += max(0ll,b[j]-a[i]);
        }
        if(res <= k)ans = max(ans,mid);
    }
    int sum = 0;
    for(int i = 1; i <= ans;i++)sum += b[i];
    cout << ans << " " << max(sum-k,0ll) <<  endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

//#define int long long

int a[1200000],b[1000002];

int main()
{
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    //cin >>  n >> m >> k;
    for(int i = 1; i <= n;i++)scanf("%d",&a[i]);
    for(int j = 1; j <= m;j++)scanf("%d",&b[j]);
    sort(a+1,a+1+n,greater<int>());
    sort(b+1,b+1+m);
    int mid,l=1,r=m;
    int ans = 0;
    while(r-l > 2){
        mid =(l+r)/2;
        if(mid > n){r = mid-1;continue;}
        long long res = 0ll;
        for(int i = 1,j = mid; i <= mid;i++,j--){
            res += max(0,b[j]-a[i]);
            if(res > k)break;
        }
        if(res <= k){
            ans = mid;
            l = mid+1;
        }
        else r = mid-1;
    }
    for(mid = l; mid <= r;mid++){
        if(mid > n){r = mid-1;break;}
        long long res = 0;
        for(int i = 1,j = mid; i <= mid;i++,j--){
            res += max(0,b[j]-a[i]);
        }
        if(res <= k)ans = max(ans,mid);
    }
    long long sum = 0;
    for(int i = 1; i <= ans;i++)sum += b[i];
    printf("%d %lld\n",ans,max(sum-k,0ll));
    //cout << ans << " " <<  <<  endl;

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int a[100001],b[100001];

int main()
{
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    for(int i = 1; i <= n;i++)scanf("%d",&a[i]);
    for(int j = 1; j <= m;j++)scanf("%d",&b[j]);
    sort(a+1,a+1+n,greater<int>());
    sort(b+1,b+1+m);
    int mid,l=1,r=m;
    int ans = 0;
    while(r-l > 2){
        mid =(l+r)/2;
        if(mid > n){r = mid-1;continue;}
        long long res = 0ll;
        for(int i = 1,j = mid; i <= mid;i++,j--){
            res += max(0,b[j]-a[i]);
            if(res > k)break;
        }
        if(res <= k){
            ans = mid;
            l = mid+1;
        }
        else r = mid-1;
    }
    for(mid = l; mid <= r;mid++){
        if(mid > n){r = mid-1;break;}
        long long res = 0;
        for(int i = 1,j = mid; i <= mid;i++,j--){
            res += max(0,b[j]-a[i]);
            if(res > k)break;
        }
        if(res <= k)ans = max(ans,mid);
    }
    long long sum = 0;
    for(int i = 1; i <= ans;i++)sum += b[i];
    printf("%d %lld\n",ans,max(sum-k,0ll));
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int ara[1000000];
int price[1000000];

int main()
{
    int n,m,k;
    cin >> n >> m >> k;
    for(int i = 1; i <= n;i++)cin >> ara[i];
    for(int i = 1; i <= m;i++)cin >> price[i];
    sort(ara+1,ara+n+1);
    sort(price+1,price+m+1);
    int cnt = 0;
    int cost = 0;
    int pos = 1;
    for(int i = 1; i <= n;i++){
        if(price[pos] <= ara[i]){
            //cout << i <<  " " << pos << endl;
            cost += price[pos];
            cnt++;pos++;
        }
        else if(price[pos] <= ara[i]+k){
           // cout << ara[i] << " " << price[pos] << endl;
            cost += ara[i];
            cnt++;
            int pp = price[pos]-ara[i];
            k -= pp;
            pos++;
            //cout << "k = " << k << endl;
        }
    }
    //cout << pos << endl;
    cout << cnt << " " << cost-k <<  endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int ara[1000000];
int price[1000000];

int main()
{
    int n,m,k;
    cin >> n >> m >> k;
    for(int i = 1; i <= n;i++)cin >> ara[i];
    for(int i = 1; i <= m;i++)cin >> price[i];
    sort(ara+1,ara+n+1);
    sort(price+1,price+m+1);
    int cnt = 0;
    int cost = 0;
    int pos = 1;
    for(int i = 1; i <= n;i++){
        if(price[pos] <= ara[i] and pos <= m){
            //cout << i <<  " " << pos << endl;
            cost += price[pos];
            cnt++;pos++;
        }
        else if(price[pos] <= ara[i]+k and pos <= m){
           // cout << ara[i] << " " << price[pos] << endl;
            cost += ara[i];
            cnt++;
            int pp = price[pos]-ara[i];
            k -= pp;
            pos++;
            //cout << "k = " << k << endl;
        }
    }
    //cout << k << endl;
    //cout << pos << endl;
    cout << cnt << " " << max(0,cost-k) <<  endl;

    return 0;
}


#include <algorithm>
#include <functional>
#include <cstdio>

#define MAX_N 100000

using namespace std;

int b[MAX_N];
int p[MAX_N];

#ifdef _WIN32
int getchar_unlocked()
{
	return getchar();
}
#endif

int skip_whitespace()
{
	int ch;
	while (true) {
		ch = getchar_unlocked();
		if (ch != ' ' && ch != '\n')
			break;
	}
	return ch;
}

template<typename T>
T read_unsigned_integer()
{
	T result = (T) 0;
	int ch = skip_whitespace();
	while (ch >= '0' && ch <= '9') {
		result = 10 * result + (ch - '0');
		ch = getchar_unlocked();
	}
	return result;
}

template<typename T>
T read_signed_integer()
{
	T result = (T) 0;
	bool flip = false;
	int ch = skip_whitespace();
	if (ch == '-') {
		flip = true;
		ch = skip_whitespace();
	}
	while (ch >= '0' && ch <= '9') {
		result = 10 * result + (ch - '0');
		ch = getchar_unlocked();
	}
	return flip ? -result : result;
}

int solve_problem()
{
	int n, m, a;

	n = read_unsigned_integer<int>();
	m = read_unsigned_integer<int>();
	a = read_unsigned_integer<int>();

	for (int i = 0; i < n; i++)
		b[i] = read_unsigned_integer<int>();

	sort(b, b + n, greater<int>());

	for (int i = 0; i < m; i++)
		p[i] = read_unsigned_integer<int>();

	sort(p, p + m);

	int left = 0;
	int right = min(n, m);
	while (left < right) {
		int mid = left + (right - left + 1) / 2;
		long long s = 0;
		for (int i = 0; i < mid; i++)
			s += max(p[i] - b[mid - 1 - i], 0);
		if (s > a)
			right = mid - 1;
		else
			left = mid;
	}

	int own = 0;
	for (int i = 0; i < left; i++) {
		own += min(p[i], b[left - 1 - i]);
		a -= max(p[i] - b[left - 1 - i], 0);
	}
	printf("%d %d\n", left, max(own - a, 0));

	return 0;
}

int main()
{
	solve_problem();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=1000000;
long long int b[N],p[N];
int main(){
    int n,k,m;
    cin >> n >> k >> m;

    for (int i=0;i<n;i++){
        cin >> b[i];
    }
    for (int i=0;i<k;i++){
        cin >> p[i];
    }
    sort(p,p+k);
    sort(b,b+n);
    long long int l=0,r=k+1,mid,p1=0,t;
    while (r-l>1){
        p1=0;
        t=m;
        mid=(r+l)/2;
        if (mid>n){
            for (int i=0;i<n;i++){
                if (b[i]<p[i-(n-mid)]){
                    t-=p[i]-b[i];
                }
            }
            for (int i=n;i<mid;i++){
                t-=p[i];
            }
        }
        else{
        for (int i=n-mid;i<n;i++){
            if (b[i]<p[i-(n-mid)]){
                t-=p[i-(n-mid)]-b[i];
            }
        }
        }
        if (t>=0){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    long long int s=0;
    for (int i=0;i<l;i++){
        s+=p[i];
    }
    cout << l << " " << max((long long)0,s-m)  ;

}


#include <bits/stdc++.h>
using namespace std;
const int N=1000000;
long long int b[N],p[N];
int main(){
    int n,k,m;
    cin >> n >> k >> m;

    for (int i=0;i<n;i++){
        cin >> b[i];
    }
    for (int i=0;i<k;i++){
        cin >> p[i];
    }
    sort(p,p+k);
    sort(b,b+n);
    long long int l=0,r=k+1,mid,p1=0,t;
    while (r-l>1){
        p1=0;
        t=m;
        mid=(r+l)/2;
        if (mid>n){
            for (int i=0;i<n;i++){
                if (b[i]<p[i]){
                    t-=p[i]-b[i];
                }
            }
            for (int i=n;i<mid;i++){
                t-=p[i];
            }
        }
        else{
            for (int i=n-mid;i<n;i++){
                if (b[i]<p[i-(n-mid)]){
                    t-=p[i-(n-mid)]-b[i];
                }
            }
        }
        if (t>=0){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    long long int s=0;
    for (int i=0;i<l;i++){
        s+=p[i];
    }
    cout << l << " " << max((long long)0,s-m)  ;

}


#include <bits/stdc++.h>
using namespace std;
const int N=1000000;
long long int b[N],p[N];
int main(){
    int n,k,m;
    cin >> n >> k >> m;

    for (int i=0;i<n;i++){
        cin >> b[i];
    }
    for (int i=0;i<k;i++){
        cin >> p[i];
    }
    sort(p,p+k);
    sort(b,b+n);
    long long int l=0,r=min(k+1,n+1),mid,p1=0,t;
    while (r-l>1){
        p1=0;
        t=m;
        mid=(r+l)/2;

            for (int i=n-mid;i<n;i++){
                if (b[i]<p[i-(n-mid)]){
                    t-=p[i-(n-mid)]-b[i];
                }
            }

        if (t>=0){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    long long int s=0;
    for (int i=0;i<l;i++){
        s+=p[i];
    }
    cout << l << " " << max((long long)0,s-m)  ;

}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k,m;
    cin >> n >> k >> m;
    int b[n],p[k];
    for (int i=0;i<n;i++){
        cin >> b[i];
    }
    for (int i=0;i<k;i++){
        cin >> p[i];
    }
    sort(p,p+k);
    sort(b,b+n);
    int l=0,r=n+1,mid,p1=0,t;
    while (r-l>1){
        p1=0;
        t=m;
        mid=(r+l)/2;
        for (int i=n-mid;i<n;i++){
            if (b[i]<p[i-(n-mid)]){
                t-=p[i-(n-mid)]-b[i];
            }
        }
        if (t>=0){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    int s=0;
    for (int i=0;i<l;i++){
        s+=p[i];
    }
    cout << l << " " << max(0,s-m)  ;

}


#include <bits/stdc++.h>
using namespace std;
const int N=1000000;
long long int b[N],p[N];
int main(){
    int n,k,m;
    cin >> n >> k >> m;

    for (int i=0;i<n;i++){
        cin >> b[i];
    }
    for (int i=0;i<k;i++){
        cin >> p[i];
    }
    sort(p,p+k);
    sort(b,b+n);
    int l=0,r=n+1,mid,p1=0,t;
    while (r-l>1){
        p1=0;
        t=m;
        mid=(r+l)/2;
        for (int i=n-mid;i<n;i++){
            if (b[i]<p[i-(n-mid)]){
                t-=p[i-(n-mid)]-b[i];
            }
        }
        if (t>=0){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    long long int s=0;
    for (int i=0;i<l;i++){
        s+=p[i];
    }
    cout << l << " " << max((long long)0,s-m)  ;

}


#include <bits/stdc++.h>
using namespace std;
const int N=1000000;
long long int b[N],p[N];
int main(){
    int n,k,m;
    cin >> n >> k >> m;

    for (int i=0;i<n;i++){
        cin >> b[i];
    }
    for (int i=0;i<k;i++){
        cin >> p[i];
    }
    sort(p,p+k);
    sort(b,b+n);
    int l=0,r=k+1,mid,p1=0,t;
    while (r-l>1){
        p1=0;
        t=m;
        mid=(r+l)/2;

        for (int i=n-mid;i<n;i++){
            if (b[i]<p[i-(n-mid)]){
                t-=p[i-(n-mid)]-b[i];
            }
        }
        if (t>=0){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    long long int s=0;
    for (int i=0;i<l;i++){
        s+=p[i];
    }
    cout << l << " " << max((long long)0,s-m)  ;

}


#include <iostream>
#include <cstdio>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iterator>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define x0 abc
#define y0 ABC
#define x1 abcd
#define y1 ABCD
#define xn abcde
#define yn ABCDE

#define l_b lower_bound
#define u_b upper_bound

#define in insert
#define er erase

#define fi first
#define se second
#define m_p make_pair

#define p_b push_back
#define po_b pop_back

#define uns unsigned

#define ld long double
#define ll long long

#define cont continue
#define re return

#define MAXLL 9000000000000000000LL
#define MAXINT 2000000000

#define MINLL -9000000000000000000LL
#define MININT -2000000000

#define pi acos(-1.)

#define endl '\n'

#define OUT cout << "-------" << endl;

using namespace std;

using namespace __gnu_pbds;

typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int a[120001], b[120001], n, m, i, s, l, r, mid, sum, sum1, ans, ans1;

    bool can(int k)
    {
        sum = 0;

        for (i = 1; i <= k; i++) sum += max(b[i] - a[n - k + i], 0);

        if (sum > s)
        re 0;

        sum1 = 0;

        for (i = 1; i <= k; i++) sum1 += b[i];

        sum1 -= s;

        re 1;
    }

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m >> s;

    for (i = 1; i <= n; i++) cin >> a[i];

    for (i = 1; i <= m; i++) cin >> b[i];

    sort(a + 1, a + 1 + n);

    sort(b + 1, b + 1 + m);

    l = 1;

    r = min(n, m);

    while (l <= r) {
        mid = (l + r) / 2;

        if (can(mid)) {
            l = mid + 1;

            ans = mid;

            ans1 = sum1;
        }
        else r = mid - 1;
    }

    cout << ans << " " << ans1 << endl;

    re 0;
}


#include <iostream>
#include <cstdio>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iterator>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define x0 abc
#define y0 ABC
#define x1 abcd
#define y1 ABCD
#define xn abcde
#define yn ABCDE

#define l_b lower_bound
#define u_b upper_bound

#define in insert
#define er erase

#define fi first
#define se second
#define m_p make_pair

#define p_b push_back
#define po_b pop_back

#define uns unsigned

#define ld long double
#define ll long long

#define cont continue
#define re return

#define MAXLL 9000000000000000000LL
#define MAXINT 2000000000

#define MINLL -9000000000000000000LL
#define MININT -2000000000

#define pi acos(-1.)

#define endl '\n'

#define OUT cout << "-------" << endl;

using namespace std;

using namespace __gnu_pbds;

typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int a[120001], b[120001], n, m, i, s, l, r, mid, sum, sum1, ans, ans1;

    bool can(int k)
    {
        sum = 0;

        for (i = 1; i <= k; i++) sum += max(b[i] - a[n - k + i], 0);

        if (sum > s)
        re 0;

        sum1 = 0;

        for (i = 1; i <= k; i++) sum1 += b[i];

        sum1 = max(sum1 - s, 0);

        re 1;
    }

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m >> s;

    for (i = 1; i <= n; i++) cin >> a[i];

    for (i = 1; i <= m; i++) cin >> b[i];

    sort(a + 1, a + 1 + n);

    sort(b + 1, b + 1 + m);

    l = 1;

    r = min(n, m);

    while (l <= r) {
        mid = (l + r) / 2;

        if (can(mid)) {
            l = mid + 1;

            ans = mid;

            ans1 = sum1;
        }
        else r = mid - 1;
    }

    cout << ans << " " << ans1 << endl;

    re 0;
}


#include <iostream>
#include <cstdio>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iterator>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define x0 abc
#define y0 ABC
#define x1 abcd
#define y1 ABCD
#define xn abcde
#define yn ABCDE

#define l_b lower_bound
#define u_b upper_bound

#define in insert
#define er erase

#define fi first
#define se second
#define m_p make_pair

#define p_b push_back
#define po_b pop_back

#define uns unsigned

#define ld long double
#define ll long long

#define cont continue
#define re return

#define MAXLL 9000000000000000000LL
#define MAXINT 2000000000

#define MINLL -9000000000000000000LL
#define MININT -2000000000

#define pi acos(-1.)

#define endl '\n'

#define OUT cout << "-------" << endl;

using namespace std;

using namespace __gnu_pbds;

typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll a[120001], b[120001], n, m, i, s, l, r, mid, sum, sum1, ans, ans1;

    bool can(ll k)
    {
        sum = 0;

        for (i = 1; i <= k; i++) sum += max(b[i] - a[n - k + i], 0LL);

        if (sum > s)
        re 0;

        sum1 = 0;

        for (i = 1; i <= k; i++) sum1 += b[i];

        sum1 = max(sum1 - s, 0LL);

        re 1;
    }

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m >> s;

    for (i = 1; i <= n; i++) cin >> a[i];

    for (i = 1; i <= m; i++) cin >> b[i];

    sort(a + 1, a + 1 + n);

    sort(b + 1, b + 1 + m);

    l = 1;

    r = min(n, m);

    while (l <= r) {
        mid = (l + r) / 2;

        if (can(mid)) {
            l = mid + 1;

            ans = mid;

            ans1 = sum1;
        }
        else r = mid - 1;
    }

    cout << ans << " " << ans1 << endl;

    re 0;
}


#include <bits/stdc++.h>
using namespace std;

#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long

#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>

#define infi INT_MAX
#define infl LONG_LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll>
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;

inline ll ceil(ll a,ll b)
{
  return (a+b-1)/b;
}

void func()
{
  ll n,k,p;
  cin>>n>>k>>p;
  ll arr[n],cnt0=0,cnt1=0;
  vll v0,v1;
  f(i,0,n)
  {
    cin>>arr[i];
    if(arr[i]%2==0)
    {
      cnt0++;
      v0.pb(arr[i]);
    }
    else
    {
      cnt1++;
      v1.pb(arr[i]);
    }
  }
  ll x=cnt1-(k-p);
  if(x>=0)
  {
    if(x%2==0)
    {
      x/=2;
      if(cnt0+x>=p)
      {
        cout<<"YES\n";
        f(i,0,k-p)
        {
          cout<<"1 "<<v1[i]<<endl;
        }
        if(cnt0<p)
        {
          f(i,0,cnt0) cout<<"1 "<<v0[i]<<endl;
          p-=cnt0;
          f(i,0,p-1)
          {
            cout<<"2 "<<v1[k-p+2*i]<<" "<<v1[k-p+2*i+1]<<endl;
          }
          cout<<v1.size()-(k+p-(ll)2)<<" ";
          f(i,k+p-2,v1.size()) cout<<v1[i]<<" ";
          cout<<endl;
        }
        else
        {
          f(i,0,p-1) cout<<"1 "<<v0[i]<<endl;
          cout<<(cnt0-(p-1))+(2*x)<<" ";
          f(i,p-1,v0.size()) cout<<v0[i]<<" ";
          f(i,k-p,v1.size()) cout<<v1[i]<<" ";
          cout<<endl;
        }
      }
      else cout<<"NO\n";
    }

    else cout<<"NO\n";
  }
  else cout<<"NO\n";
}

int main()
{
    fast
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

    ll ntc=1;
    //cin>>ntc;

    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
      func();
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
#define ld long double

#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>

#define infi INT_MAX
#define infl LONG_LONG_MAX
#define infd LDBL_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll>
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define deb printf("***************************************************************************************\n");
#define moshi printf("moshi moshi ! \n");
#define hi printf("hi ! \n");
#define bye printf("bye bye ! \n");

//template<typename T>
//#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

//const ll N=1e6+7;
//ll p=998244353;
//ll fac[N];
/*
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

inline ll ceil(ll a,ll b)
{
  return (a+b-1)/b;
}

ll max(ll x,ll y,ll z)
{
  return max(x,max(y,z));
}

ll modpro(ll x,ll y,ll z=1)
{
  x%=p;
  y%=p;
  z%=p;
  ll res=(x*y)%p;
  res=(res*z)%p;
  return res;
}

ll modadd(ll x,ll y,ll z=0)
{
  ll res=(x+y)%p;
  res=(res+z)%p;
  return res;
}

ll pow_mod_p(ll a,ll b)
{
  a=a%p;
  ll res=1;
  while(b>0)
  {
    if(b&1) res=(res*a)%p;
    b=b>>1;
    a=(a*a)%p;
  }
  return res;
}

inline ll mod_inv(ll x)
{
  return pow_mod_p(x,p-2);
}*/

/*
ll nCr(ll x,ll y)
{
  if(x<y) return 0;
  ll res=fac[x];
  ll den=(fac[y]*fac[x-y])%p;
  ll deni=mod_inv(den);
  res=(res*deni)%p;
  return res;
}*/

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

// resize : str.resize(new_size)   new size <= old size

const ll N=1e5+5;
ll b[N],p[N],n,m,a;

bool can(ll x)
{
  ll bal=a;
  f(i,1,x+1)
  {
    ll j=n-x+i;
    if(p[i]<=b[j]) continue;
    ll cost=p[i]-b[j];
    if(cost>bal) return 0;
    else bal-=cost;
  }
  return 1;
}

void func()
{
  cin>>n>>m>>a;

  f(i,1,n+1) cin>>b[i];
  f(i,1,m+1) cin>>p[i];

  sort(b+1,b+1+n);
  sort(p+1,p+m+1);

  ll l=0,r=min(n,m),ans=-1;
  while(l<=r)
  {
    ll mid=(l+r)/2;
    if(can(mid)) ans=mid,l=mid+1;
    else r=mid-1;
  }

  if(ans==0)
  {
    cout<<"0 0\n";
    return;
  }

  ll cost=0;
  f(i,1,ans+1) cost+=p[i];
  ll xx=cost-a;
  pr2(ans,xx) nl
}

int main()
{
    fast
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE*/

    ll ntc=1;
    //cin>>ntc;

    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
      func();
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
#define ld long double

#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>

#define infi INT_MAX
#define infl LONG_LONG_MAX
#define infd LDBL_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll>
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define deb printf("***************************************************************************************\n");
#define moshi printf("moshi moshi ! \n");
#define hi printf("hi ! \n");
#define bye printf("bye bye ! \n");

//template<typename T>
//#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

//const ll N=1e6+7;
//ll p=998244353;
//ll fac[N];
/*
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

inline ll ceil(ll a,ll b)
{
  return (a+b-1)/b;
}

ll max(ll x,ll y,ll z)
{
  return max(x,max(y,z));
}

ll modpro(ll x,ll y,ll z=1)
{
  x%=p;
  y%=p;
  z%=p;
  ll res=(x*y)%p;
  res=(res*z)%p;
  return res;
}

ll modadd(ll x,ll y,ll z=0)
{
  ll res=(x+y)%p;
  res=(res+z)%p;
  return res;
}

ll pow_mod_p(ll a,ll b)
{
  a=a%p;
  ll res=1;
  while(b>0)
  {
    if(b&1) res=(res*a)%p;
    b=b>>1;
    a=(a*a)%p;
  }
  return res;
}

inline ll mod_inv(ll x)
{
  return pow_mod_p(x,p-2);
}*/

/*
ll nCr(ll x,ll y)
{
  if(x<y) return 0;
  ll res=fac[x];
  ll den=(fac[y]*fac[x-y])%p;
  ll deni=mod_inv(den);
  res=(res*deni)%p;
  return res;
}*/

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

// resize : str.resize(new_size)   new size <= old size

const ll N=1e5+5;
ll b[N],p[N],n,m,a;

bool can(ll x)
{
  ll bal=a;
  f(i,1,x+1)
  {
    ll j=n-x+i;
    if(p[i]<=b[j]) continue;
    ll cost=p[i]-b[j];
    if(cost>bal) return 0;
    else bal-=cost;
  }
  return 1;
}

void func()
{
  cin>>n>>m>>a;

  f(i,1,n+1) cin>>b[i];
  f(i,1,m+1) cin>>p[i];

  sort(b+1,b+1+n);
  sort(p+1,p+m+1);

  ll l=0,r=min(n,m),ans=-1;
  while(l<=r)
  {
    ll mid=(l+r)/2;
    if(can(mid)) ans=mid,l=mid+1;
    else r=mid-1;
  }

  if(ans==0)
  {
    cout<<"0 0\n";
    return;
  }

  ll cost=0;
  f(i,1,ans+1) cost+=p[i];
  ll xx=max(cost-a,(ll)0);
  pr2(ans,xx) nl
}

int main()
{
    fast
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE*/

    ll ntc=1;
    //cin>>ntc;

    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
      func();
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;

const int modo=1e9+7;
const ll inf=1e16;
const ll ms=(1e5) +5;

ll ar[ms];
ll br[ms];

int main()
{
    idfc;
    ll n,m,s;
    cin>>n>>m>>s;
    int i;
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    for(i=1;i<=m;i++)
    {
        cin>>br[i];
    }
    ll ans=0;
    ll pp=0;
    ll l=1;
    ll r=min(n,m);
    ll mid;
    sort(br+1,br+m+1);
    sort(ar+1,ar+n+1,greater<>());
    ll sum=0;
    ll s2=0;
    ll tt;
    ll kk=0;
    while (l<=r)
    {
        mid=(l+r)>>1;
        sum=0;
        s2=s;
        for(i=1;i<=mid;i++)sum+=br[i];

        for(i=1;i<=mid;i++)
        {
          tt=min(ar[i],br[mid+1-i]);
          tt=min(max(0ll,sum-s2),tt);
          s2+=tt;
          kk+=tt;
        }
      //  cout<<mid<<" "<<sum<<" "<<s2<<endl;
        if(s2>=sum)
        {
            if(mid>ans)
            {
                ans=mid;
                pp=kk;
            }
            l=mid+1;
        }
        else{
            r=mid-1;
        }
    }
    cout<<ans<<" "<<pp;
}


#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;

const int modo=1e9+7;
const ll inf=1e16;
const ll ms=(1e5) +5;

ll ar[ms];
ll br[ms];

int main()
{
    idfc;
    ll n,m,s;
    cin>>n>>m>>s;
    int i;
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    for(i=1;i<=m;i++)
    {
        cin>>br[i];
    }
    ll ans=0;
    ll pp=0;
    ll l=1;
    ll r=m;
    ll mid;
    sort(br+1,br+m+1);
    sort(ar+1,ar+n+1,greater<>());
    ll sum=0;
    ll s2=0;
    ll tt;
    ll kk=0;
    r=min(n,m);
    while (l<=r)
    {
        mid=(l+r)>>1;
        sum=0;
        kk=0;
        s2=s;
        for(i=1;i<=mid;i++)sum+=br[i];

        for(i=1;i<=mid;i++)
        {
            tt=min(ar[i],br[mid+1-i]);
            tt=min(max(0ll,sum-s2),tt);
            s2+=tt;
            kk+=tt;
        }
        //  cout<<mid<<" "<<sum<<" "<<s2<<endl;
        if(s2>=sum)
        {
            if(mid>ans)
            {
                ans=mid;
                pp=kk;
            }
            l=mid+1;
        }
        else{
            r=mid-1;
        }
    }
    cout<<ans<<" "<<pp;
}


#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;

const int modo=1e9+7;
const ll inf=1e16;
const ll ms=(1e5) +5;

ll ar[ms];
ll br[ms];

int main()
{
    idfc;
    ll n,m,s;
    cin>>n>>m>>s;
    int i;
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    for(i=1;i<=m;i++)
    {
        cin>>br[i];
    }
    ll ans=0;
    ll pp=0;
    ll l=1;
    ll r=m;
    ll mid;
    sort(br+1,br+m+1);
    sort(ar+1,ar+n+1,greater<>());
    ll sum=0;
    ll s2=0;
    ll tt;
    ll kk=0;
    while (l<=r)
    {
        mid=(l+r)>>1;
        sum=0;
        s2=s;
        for(i=1;i<=mid;i++)sum+=br[i];

        for(i=1;i<=mid;i++)
        {
          tt=min(ar[i],br[mid+1-i]);
          tt=min(max(0ll,sum-s2),tt);
          s2+=tt;
          kk+=tt;
        }
      //  cout<<mid<<" "<<sum<<" "<<s2<<endl;
        if(s2>=sum)
        {
            if(mid>ans)
            {
                ans=mid;
                pp=kk;
            }
            l=mid+1;
        }
        else{
            r=mid-1;
        }
    }
    cout<<ans<<" "<<pp;
}


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <tr1/unordered_map>
#define ll long long
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define pl pair<ll,ll>
#define umap tr1::unordered_map
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed<<setprecision(10);
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pset;
const ll N = 1e5 + 3, mod = 1e9 + 7;

int main()
{
	fastIO
	ll n, m, a;
	cin>>n>>m>>a;
	ll b[n], p[m];
	for(ll i = 0; i < n; i++)
	{
		cin>>b[i];
	}
	for(ll i = 0; i < m; i++)
	{
		cin>>p[i];
	}
	sort(b, b + n);
	sort(p, p + m);
	ll st = 0, ed = min(n, m), ans = 0;
	while(st <= ed)
	{
		ll mid = (st + ed) >> 1LL, x = 0;
		for(ll i = 0; i < mid; i++)
		{
			x += max(0LL, p[i] - b[n - mid + i]);
		}
		if(x <= a)
		{
			ans = mid;
			st = mid + 1;
		}
		else
		{
			ed = mid - 1;
		}
	}
	if(!ans) cout<<ans<<" 0";
	else
	{
		cout<<ans<<" ";
		ll sum = 0;
		for(ll i = 0; i < ans; i++)
		{
			sum += p[i];
		}
		cout<<max(0LL, sum - a);
	}
	return 0;
}


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <tr1/unordered_map>
#define ll long long
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define pl pair<ll,ll>
#define umap tr1::unordered_map
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed<<setprecision(10);
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pset;
const ll N = 1e5 + 3, mod = 1e9 + 7;

int main()
{
	fastIO
	ll n, m, a;
	cin>>n>>m>>a;
	ll b[n], p[m];
	for(ll i = 0; i < n; i++)
	{
		cin>>b[i];
	}
	for(ll i = 0; i < m; i++)
	{
		cin>>p[i];
	}
	sort(b, b + n);
	sort(p, p + m);
	ll st = 0, ed = min(n, m), ans = 0;
	while(st <= ed)
	{
		ll mid = (st + ed) >> 1LL, x = 0;
		for(ll i = 0; i < mid; i++)
		{
			x += max(0LL, p[i] - b[n - mid + i]);
		}
		if(x <= a)
		{
			ans = mid;
			st = mid + 1;
		}
		else
		{
			ed = mid - 1;
		}
	}
	if(!ans) cout<<ans<<" 0";
	else
	{
		cout<<ans<<" ";
		ll sum = 0;
		for(ll i = 0; i < ans; i++)
		{
			sum += p[i];
		}
		cout<<(sum - a);
	}
	return 0;
}


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <tr1/unordered_map>
#define ll long long
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define pl pair<ll,ll>
#define umap tr1::unordered_map
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed<<setprecision(10);
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pset;
const ll N = 1e5 + 3, mod = 1e9 + 7;

int main()
{
	fastIO
	ll n, m, a;
	cin>>n>>m>>a;
	ll b[n], p[m];
	for(ll i = 0; i < n; i++)
	{
		cin>>b[i];
	}
	for(ll i = 0; i < m; i++)
	{
		cin>>p[i];
	}
	sort(b, b + n);
	sort(p, p + m);
	ll st = 0, ed = min(n, m), ans = 0;
	while(st <= ed)
	{
		ll mid = (st + ed) >> 1LL, x = 0;
		for(ll i = 0; i < mid; i++)
		{
			x += max(0LL, p[i] - b[n - mid + i]);
		}
		if(x <= a)
		{
			ans = mid;
			st = mid + 1;
		}
		else
		{
			ed = mid - 1;
		}
	}
	cout<<ans<<" ";
	ll sum = 0;
	for(ll i = 0; i < ans; i++)
	{
		sum += p[i];
	}
	cout<<max(0LL, sum - a);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 100;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

#define ll long long
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define X first
#define Y second

ll n, m, c, a[MAXN], b[MAXN];

ll cal(ll x){
	// minimum of c

	ll ans = 0;

	for(ll i = 0; i < x; i++){
		ans += max(0ll, b[i] - a[n - x + i]);
	}

	return ans;
}

ll isval(ll x){
	//cout << x << " => " << cal(x) << endl;
	return cal(x) > c;
}

ll binary_search(){
	ll l = 0, r = min(n, m), mi;
	while(r - l > 1){
		//cout << l << " " << r << endl;
		mi = (l + r) / 2;
		if(isval(mi)){
			r = mi;
		}
		else{
			l = mi;
		}
	}
	return l;
}

void cal2(ll x){

	cout << x << " ";

	ll ans = 0;

	for(ll i = 0; i < x; i++){
		ans += b[i];
	}

	cout << ans - c;

	return;
}

int main(){
	fast_io;

	cin >> n >> m >> c;

	for(ll i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);

	for(ll i = 0; i < m; i++){
		cin >> b[i];
	}
	sort(b, b + m);

	cal2(binary_search());

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 100;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

#define ll long long
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define X first
#define Y second

ll n, m, c, a[MAXN], b[MAXN];

ll cal(ll x){
	// minimum of c

	ll ans = 0;

	for(ll i = 0; i < x; i++){
		ans += max(0ll, b[i] - a[n - x + i]);
	}

	return ans;
}

ll isval(ll x){
	//cout << x << " => " << cal(x) << endl;
	return cal(x) > c;
}

ll binary_search(){
	ll l = 0, r = min(n, m) + 1, mi;
	while(r - l > 1){
		//cout << l << " " << r << endl;
		mi = (l + r) / 2;
		if(isval(mi)){
			r = mi;
		}
		else{
			l = mi;
		}
	}
	return l;
}

void cal2(ll x){

	cout << x << " ";

	ll ans = 0;

	for(ll i = 0; i < x; i++){
		ans += b[i];
	}

	cout << max(0ll, ans - c);

	return;
}

int main(){
	fast_io;

	cin >> n >> m >> c;

	for(ll i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);

	for(ll i = 0; i < m; i++){
		cin >> b[i];
	}
	sort(b, b + m);

	cal2(binary_search());

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 100;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

#define ll long long
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define X first
#define Y second

ll n, m, c, a[MAXN], b[MAXN];

ll cal(ll x){
	// minimum of c

	ll ans = 0;

	for(ll i = 0; i < x; i++){
		ans += max(0ll, b[i] - a[n - x + i]);
	}

	return ans;
}

ll isval(ll x){
	//cout << x << " => " << cal(x) << endl;
	return cal(x) >= c;
}

ll binary_search(){
	ll l = 0, r = n, mi;
	while(r - l > 1){
		//cout << l << " " << r << endl;
		mi = (l + r) / 2;
		if(isval(mi)){
			r = mi;
		}
		else{
			l = mi;
		}
	}
	return r;
}

void cal2(ll x){

	cout << x << " ";

	ll ans = 0;

	for(ll i = 0; i < x; i++){
		ans += b[i];
	}

	cout << ans - c;

	return;
}

int main(){
	fast_io;

	cin >> n >> m >> c;

	for(ll i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);

	for(ll i = 0; i < m; i++){
		cin >> b[i];
	}
	sort(b, b + m);

	cal2(binary_search());

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 100;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

#define ll long long
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define X first
#define Y second

ll n, m, c, a[MAXN], b[MAXN];

ll cal(ll x){
	// minimum of c

	ll ans = 0;

	for(ll i = 0; i < x; i++){
		ans += max(0ll, b[i] - a[n - x + i]);
	}

	return ans;
}

ll isval(ll x){
	//cout << x << " => " << cal(x) << endl;
	return cal(x) >= c;
}

ll binary_search(){
	ll l = 0, r = min(n, m), mi;
	while(r - l > 1){
		//cout << l << " " << r << endl;
		mi = (l + r) / 2;
		if(isval(mi)){
			r = mi;
		}
		else{
			l = mi;
		}
	}
	return r;
}

void cal2(ll x){

	cout << x << " ";

	ll ans = 0;

	for(ll i = 0; i < x; i++){
		ans += b[i];
	}

	cout << ans - c;

	return;
}

int main(){
	fast_io;

	cin >> n >> m >> c;

	for(ll i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);

	for(ll i = 0; i < m; i++){
		cin >> b[i];
	}
	sort(b, b + m);

	cal2(binary_search());

	return 0;
}


#include <bits/stdc++.h>
#define mx 100010
using namespace std;

typedef long long int ll;

vector <ll> a,b;
bool taken[mx];

int main(){
    //freopen("in.txt","r",stdin);
    ll n,m,p;

    scanf("%lld %lld %lld",&n,&m,&p);
    ll tp = p;
    ll psum = 0;
    for(ll i = 0; i < n; i++){
        ll temp;

        scanf("%lld",&temp);
        a.push_back(temp);
    }

    for(ll i = 0; i < m; i++){
        ll temp;

        scanf("%lld",&temp);
        b.push_back(temp);
    }

    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    ll cnt = 0;
    ll j = 0,i;

    for(i = 0; i < a.size(); i++){
        while(b[j] > a[i] && j < b.size())
            j++;
        if(j < b.size()){
            if(b[j] <= a[i]){
                taken[j] = true;

                psum+=b[j];
                cnt++;
                //printf("psum: %lld\n",psum);
                //printf("j: %lld i: %lld b[j]: %lld a[i]: %lld\n",j,i,b[j],a[i]);
                j++;
            }
        }
        else{
            break;
        }
    }

//    printf("%lld\n",psum);
//
//    for(int i = 0; i < a.size(); i++)
//        printf("%lld ",a[i]);
//    printf("\n");
//    for(int i = 0; i < b.size(); i++)
//        printf("%lld ",b[i]);
//    printf("\n");
    j = b.size()-1;
    for(; i < a.size(); i++){
        while(taken[j] == true && j >= 0)
            j--;
        //printf("j: %lld i: %lld b[j]: %lld psum: %lld\n",j,i,b[j],psum);
        if(j >= 0){
            if(b[j]-a[i] <= tp){
                tp-=(b[j]-a[i]);
                taken[j] = true;
                psum += a[i];
                cnt++;
                //printf("entered\n");
            }
            else
                break;
        }
        else{
            break;
        }
    }
//    for(ll i = 0; i < b.size(); i++){
//        printf("%lld: %d\n",b[i],taken[i]);
//    }
//    printf("%lld\n",psum);

    i = 0, j = b.size()-1;

    while(i < j){
        while(taken[j] == true && j >= 0)
            j--;
        while(taken[i] == false && i < b.size())
            i++;
        //printf("j: %lld i: %lld\n",j,i);
        if(j >= 0 && i < b.size() && i < j){
            //printf("%lld %lld\n\n",b[j],a[i]);
            psum -= (b[i]-b[j]);
            taken[j] = false;
            taken[i] = true;
            i++;
            j--;
        }
    }

    psum -= tp;
    psum = max(ll(0),psum);

    printf("%lld %lld",cnt,psum);

}


#include <bits/stdc++.h>
#define mx 100010
using namespace std;

typedef long long int ll;

vector <ll> a,b;
bool taken[mx];

int main(){
    //freopen("in.txt","r",stdin);
    ll n,m,p;

    scanf("%lld %lld %lld",&n,&m,&p);
    ll tp = p;
    for(ll i = 0; i < n; i++){
        ll temp;

        scanf("%lld",&temp);
        a.push_back(temp);
    }

    for(ll i = 0; i < m; i++){
        ll temp;

        scanf("%lld",&temp);
        b.push_back(temp);
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    vector <ll> tak;

    ll last = b.size()-1;
    ll first = 0;
    ll psum = 0;
    ll cnt = 0;

    ll i;
    for(i = a.size()-1; i >= 0; i--){
        ll hi = last;
        ll lo = first;

        while(lo < hi){

            ll mid = (lo + hi + 1) /2;

            if(b[mid] > a[i])
                hi = mid-1;
            else if(b[mid] <= a[i])
                lo = mid;
        }

        if(b[lo] > a[i])
            break;
        else{
            psum += b[lo];
            //printf("%lld ",b[lo]);
            cnt++;
            taken[lo] = true;
            last = lo-1;
            tak.push_back(b[lo]);
        }
    }
    while(taken[first])
        first++;

    for(; i >= 0 && first < b.size(); i--){
        if(b[first] - a[i] <= tp){
            tp -= (b[first] - a[i]);
            psum += a[i];
            cnt++;
            first++;
            taken[i] = true;
        }
        else
            break;
    }

    priority_queue <ll> left;

    for(int i = 0; i < m; i++)
        if(taken[i] == false)
            left.push(-b[i]);

    sort(tak.rbegin(),tak.rend());

    ll idx = 0;
    while(!left.empty() && idx < tak.size()){
        ll u = left.top();
        left.pop();
        //printf("%lld\n",u);
        u = -u;
        if(u < tak[idx]){
            //printf("%lld %lld\n",u,tak[idx]);
            psum -= (tak[idx]-u);
            idx++;
        }
    }
    psum -= tp;
    printf("%lld %lld\n",cnt,psum);
}


#include <bits/stdc++.h>
#define mx 100010
using namespace std;

typedef long long int ll;

ll arr1[mx],arr2[mx],cumi1[mx],cumi2[mx];
ll n,m,p;

bool comp(int a, int b){
    return a > b;
}

bool ask(ll len){
    ll val1 = cumi1[len];
    ll tp = p;
    int cnt = 0;
    for(ll i = 1,j=len; i <= len && j>=1 && j <= m; i++,j--){
        if(arr1[i] >= arr2[j]){
            cnt++;
        }
        else{
            ll l = arr2[j]-arr1[i];
            if(tp >= l){
                cnt++;
                tp-=l;
            }
        }
    }

    return cnt==len;
}

ll find_cost(ll len){
    ll val1 = cumi1[len];
    ll tot = 0;

    ll tp  = p;
    for(ll i = 1,j=len; i <= len; i++,j--){
        if(arr1[i] >= arr2[j]) tot += arr2[j];
        else{
            ll l = arr2[j]-arr1[i];
            tp-=l;
            tot+=arr1[i];
        }
    }

    return max(tot - tp,(ll)0);
}
int main(){

    scanf("%lld %lld %lld",&n,&m,&p);

    for(ll i = 1; i <= n; i++)
        scanf("%lld",arr1+i);

    for(ll i = 1; i <= m; i++)
        scanf("%lld",arr2+i);

    sort(arr1+1,arr1+n+1,comp);
    sort(arr2+1,arr2+m+1);

//    for(ll i = 1; i <= n; i++){
//        printf("%lld ",arr1[i]);
//    }
//    printf("\n");
//    for(ll i = 1; i <= n)
    for(ll i = 1; i <= n; i++)
        cumi1[i] = cumi1[i-1] + arr1[i];

    for(ll i = 1; i <= m; i++)
        cumi2[i] = cumi2[i-1] + arr2[i];

    ll lo = 0,hi=n;
    ll min_cost = 0;
    while(lo < hi){

        ll mid = (lo + hi + 1)/2;

        if(ask(mid)){
            lo = mid;
        }
        else{
            hi = mid-1;
        }
    }

    min_cost = find_cost(lo);
    printf("%lld %lld\n",lo,min_cost);
}


#include <bits/stdc++.h>
#define mx 100010
using namespace std;

typedef long long int ll;

ll arr1[mx],arr2[mx],cumi1[mx],cumi2[mx];
ll n,m,p;

bool comp(int a, int b){
    return a > b;
}

bool ask(ll len){
    ll val1 = cumi1[len];
    ll tp = p;

    for(ll i = 1,j=len; i <= len; i++,j--){
        if(arr1[i] >= arr2[j]);
        else{
            ll l = arr2[j]-arr1[i];
            tp-=l;
        }
    }

    return tp >= 0;
}

ll find_cost(ll len){
    ll val1 = cumi1[len];
    ll tot = 0;

    ll tp  = p;
    for(ll i = 1,j=len; i <= len; i++,j--){
        if(arr1[i] >= arr2[j]) tot += arr2[j];
        else{
            ll l = arr2[j]-arr1[i];
            tp-=l;
            tot+=arr1[i];
        }
    }

    return tot - tp;
}
int main(){

    scanf("%lld %lld %lld",&n,&m,&p);

    for(ll i = 1; i <= n; i++)
        scanf("%lld",arr1+i);

    for(ll i = 1; i <= m; i++)
        scanf("%lld",arr2+i);

    sort(arr1+1,arr1+n+1,comp);
    sort(arr2+1,arr2+m+1);

//    for(ll i = 1; i <= n; i++){
//        printf("%lld ",arr1[i]);
//    }
//    printf("\n");
//    for(ll i = 1; i <= n)
    for(ll i = 1; i <= n; i++)
        cumi1[i] = cumi1[i-1] + arr1[i];

    for(ll i = 1; i <= m; i++)
        cumi2[i] = cumi2[i-1] + arr2[i];

    ll lo = 0,hi=n;
    ll min_cost = 0;
    while(lo < hi){

        ll mid = (lo + hi + 1)/2;

        if(ask(mid)){
            lo = mid;
        }
        else{
            hi = lo-1;
        }
    }

    min_cost = find_cost(lo);
    printf("%lld %lld\n",lo,min_cost);
}


#include <bits/stdc++.h>
#define mx 100010
using namespace std;

typedef long long int ll;

vector <ll> a,b;
bool taken[mx];

int main(){
    freopen("in.txt","r",stdin);
    ll n,m,p;

    scanf("%lld %lld %lld",&n,&m,&p);
    ll tp = p;
    for(ll i = 0; i < n; i++){
        ll temp;

        scanf("%lld",&temp);
        a.push_back(temp);
    }

    for(ll i = 0; i < m; i++){
        ll temp;

        scanf("%lld",&temp);
        b.push_back(temp);
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    vector <ll> tak;

    ll last = b.size()-1;
    ll first = 0;
    ll psum = 0;
    ll cnt = 0;

    ll i;
    for(i = a.size()-1; i >= 0; i--){
        ll hi = last;
        ll lo = first;

        while(lo < hi){

            ll mid = (lo + hi + 1) /2;

            if(b[mid] > a[i])
                hi = mid-1;
            else if(b[mid] <= a[i])
                lo = mid;
        }

        if(b[lo] > a[i])
            break;
        else{
            psum += b[lo];
            //printf("%lld ",b[lo]);
            cnt++;
            taken[lo] = true;
            last = lo-1;
            tak.push_back(b[lo]);
        }
    }
    while(taken[first])
        first++;

    for(; i >= 0 && first < b.size(); i--){
        if(b[first] - a[i] <= tp){
            tp -= (b[first] - a[i]);
            psum += a[i];
            cnt++;
            first++;
            taken[i] = true;
        }
        else
            break;
    }

    priority_queue <ll> left;

    for(int i = 0; i < m; i++)
        if(taken[i] == false)
            left.push(-b[i]);

    sort(tak.rbegin(),tak.rend());

    ll idx = 0;
    while(!left.empty() && idx < tak.size()){
        ll u = left.top();
        left.pop();
        //printf("%lld\n",u);
        u = -u;
        if(u < tak[idx]){
            //printf("%lld %lld\n",u,tak[idx]);
            psum -= (tak[idx]-u);
            idx++;
        }
    }
    psum -= tp;
    printf("%lld %lld\n",cnt,psum);
}


#include <bits/stdc++.h>
#define mx 100010
using namespace std;

typedef long long int ll;

vector <ll> a,b;
bool taken[mx];

int main(){
    //freopen("in.txt","r",stdin);
    ll n,m,p;

    scanf("%lld %lld %lld",&n,&m,&p);
    ll tp = p;
    for(ll i = 0; i < n; i++){
        ll temp;

        scanf("%lld",&temp);
        a.push_back(temp);
    }

    for(ll i = 0; i < m; i++){
        ll temp;

        scanf("%lld",&temp);
        b.push_back(temp);
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    vector <ll> tak;

    ll last = b.size()-1;
    ll first = 0;
    ll psum = 0;
    ll cnt = 0;

    ll i;
    for(i = a.size()-1; i >= 0; i--){
        ll hi = last;
        ll lo = first;

        while(lo < hi && last >= 0){

            ll mid = (lo + hi + 1) /2;

            if(b[mid] > a[i])
                hi = mid-1;
            else if(b[mid] <= a[i])
                lo = mid;
        }

        if(b[lo] > a[i] || taken[lo] || first > last)
            break;
        else{
            psum += b[lo];
            //printf("%lld ",b[lo]);
            cnt++;
            taken[lo] = true;
            last = lo-1;
            tak.push_back(b[lo]);
        }
    }
    while(taken[first])
        first++;

    for(; i >= 0 && first < b.size(); i--){
        if(b[first] - a[i] <= tp){
            tp -= (b[first] - a[i]);
            psum += a[i];
            cnt++;
            first++;
            taken[i] = true;
        }
        else
            break;
    }

    priority_queue <ll> left;

    for(int i = 0; i < m; i++)
        if(taken[i] == false)
            left.push(-b[i]);

    sort(tak.rbegin(),tak.rend());

    ll idx = 0;
    while(!left.empty() && idx < tak.size()){
        ll u = left.top();
        left.pop();
        //printf("%lld\n",u);
        u = -u;
        if(u < tak[idx]){
            //printf("%lld %lld\n",u,tak[idx]);
            psum -= (tak[idx]-u);
            idx++;
        }
    }
    psum -= tp;
    psum = max((ll)(0),psum);
    printf("%lld %lld\n",cnt,psum);
}


#include <bits/stdc++.h>
#define mx 100010
using namespace std;

typedef long long int ll;

vector <ll> a,b;
bool taken[mx];

int main(){
    //freopen("in.txt","r",stdin);
    ll n,m,p;

    scanf("%lld %lld %lld",&n,&m,&p);
    ll tp = p;
    for(ll i = 0; i < n; i++){
        ll temp;

        scanf("%lld",&temp);
        a.push_back(temp);
    }

    for(ll i = 0; i < m; i++){
        ll temp;

        scanf("%lld",&temp);
        b.push_back(temp);
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    vector <ll> tak;

    ll last = b.size()-1;
    ll first = 0;
    ll psum = 0;
    ll cnt = 0;

    ll i;
    for(i = a.size()-1; i >= 0; i--){
        ll hi = last;
        ll lo = first;

        while(lo < hi && last >= 0){

            ll mid = (lo + hi + 1) /2;

            if(b[mid] > a[i])
                hi = mid-1;
            else if(b[mid] <= a[i])
                lo = mid;
        }

        if(b[lo] > a[i] || taken[lo])
            break;
        else{
            psum += b[lo];
            //printf("%lld ",b[lo]);
            cnt++;
            taken[lo] = true;
            last = lo-1;
            tak.push_back(b[lo]);
        }
    }
    while(taken[first])
        first++;

    for(; i >= 0 && first < b.size(); i--){
        if(b[first] - a[i] <= tp){
            tp -= (b[first] - a[i]);
            psum += a[i];
            cnt++;
            first++;
            taken[i] = true;
        }
        else
            break;
    }

    priority_queue <ll> left;

    for(int i = 0; i < m; i++)
        if(taken[i] == false)
            left.push(-b[i]);

    sort(tak.rbegin(),tak.rend());

    ll idx = 0;
    while(!left.empty() && idx < tak.size()){
        ll u = left.top();
        left.pop();
        //printf("%lld\n",u);
        u = -u;
        if(u < tak[idx]){
            //printf("%lld %lld\n",u,tak[idx]);
            psum -= (tak[idx]-u);
            idx++;
        }
    }
    psum -= tp;
    printf("%lld %lld\n",cnt,psum);
}


#include <bits/stdc++.h>
#define mx 100010
using namespace std;

typedef long long int ll;

vector <ll> a,b;
bool taken[mx];

int main(){
    freopen("in.txt","r",stdin);
    ll n,m,p;

    scanf("%lld %lld %lld",&n,&m,&p);
    ll tp = p;
    for(ll i = 0; i < n; i++){
        ll temp;

        scanf("%lld",&temp);
        a.push_back(temp);
    }

    for(ll i = 0; i < m; i++){
        ll temp;

        scanf("%lld",&temp);
        b.push_back(temp);
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    vector <ll> tak;

    ll last = b.size()-1;
    ll first = 0;
    ll psum = 0;
    ll cnt = 0;

    ll i;
    for(i = a.size()-1; i >= 0; i--){
        ll hi = last;
        ll lo = first;

        while(lo < hi && last >= 0){

            ll mid = (lo + hi + 1) /2;

            if(b[mid] > a[i])
                hi = mid-1;
            else if(b[mid] <= a[i])
                lo = mid;
        }

        if(b[lo] > a[i] || taken[lo])
            break;
        else{
            psum += b[lo];
            //printf("%lld ",b[lo]);
            cnt++;
            taken[lo] = true;
            last = lo-1;
            tak.push_back(b[lo]);
        }
    }
    while(taken[first])
        first++;

    for(; i >= 0 && first < b.size(); i--){
        if(b[first] - a[i] <= tp){
            tp -= (b[first] - a[i]);
            psum += a[i];
            cnt++;
            first++;
            taken[i] = true;
        }
        else
            break;
    }

    priority_queue <ll> left;

    for(int i = 0; i < m; i++)
        if(taken[i] == false)
            left.push(-b[i]);

    sort(tak.rbegin(),tak.rend());

    ll idx = 0;
    while(!left.empty() && idx < tak.size()){
        ll u = left.top();
        left.pop();
        //printf("%lld\n",u);
        u = -u;
        if(u < tak[idx]){
            //printf("%lld %lld\n",u,tak[idx]);
            psum -= (tak[idx]-u);
            idx++;
        }
    }
    psum -= tp;
    printf("%lld %lld\n",cnt,psum);
}


#include <bits/stdc++.h>
#define mx 100010
using namespace std;

typedef long long int ll;

vector <ll> a,b;
bool taken[mx];

int main(){
    freopen("in.txt","r",stdin);
    ll n,m,p;

    scanf("%lld %lld %lld",&n,&m,&p);
    ll tp = p;
    for(ll i = 0; i < n; i++){
        ll temp;

        scanf("%lld",&temp);
        a.push_back(temp);
    }

    for(ll i = 0; i < m; i++){
        ll temp;

        scanf("%lld",&temp);
        b.push_back(temp);
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    vector <ll> tak;

    ll last = b.size()-1;
    ll first = 0;
    ll psum = 0;
    ll cnt = 0;

    ll i;
    for(i = a.size()-1; i >= 0; i--){
        ll hi = last;
        ll lo = first;

        while(lo < hi){

            ll mid = (lo + hi + 1) /2;

            if(b[mid] > a[i])
                hi = mid-1;
            else if(b[mid] <= a[i])
                lo = mid;
        }

        if(b[lo] > a[i])
            break;
        else{
            psum += b[lo];
            //printf("%lld ",b[lo]);
            cnt++;
            taken[lo] = true;
            last = lo-1;
            tak.push_back(b[lo]);
        }
    }
    while(taken[first])
        first++;

    for(; i >= 0 && first < b.size(); i--){
        if(b[first] - a[i] <= tp){
            tp -= (b[first] - a[i]);
            psum += a[i];
            cnt++;
            first++;
            taken[i] = true;
        }
        else
            break;
    }

    priority_queue <ll> left;

    for(int i = 0; i < m; i++)
        if(taken[i] == false)
            left.push(-b[i]);

    sort(tak.rbegin(),tak.rend());

    ll idx = 0;
    while(!left.empty() && idx < tak.size()){
        ll u = left.top();
        left.pop();
        //printf("%lld\n",u);
        u = -u;
        if(u < tak[idx]){
            //printf("%lld %lld\n",u,tak[idx]);
            psum -= (tak[idx]-u);
            idx++;
        }
    }
    psum -= tp;
    printf("%lld %lld\n",cnt,psum);
}
//


#include <bits/stdc++.h>
#define mx 100010
using namespace std;

typedef long long int ll;

ll arr1[mx],arr2[mx],cumi1[mx],cumi2[mx];
ll n,m,p;

bool comp(int a, int b){
    return a > b;
}

bool ask(ll len){
    ll val1 = cumi1[len];
    ll tp = p;
    int cnt = 0;
    for(ll i = 1,j=len; i <= len && j>=1 && j <= m; i++,j--){
        if(arr1[i] >= arr2[j]){
            cnt++;
        }
        else{
            ll l = arr2[j]-arr1[i];
            if(tp >= l){
                cnt++;
                tp-=l;
            }
        }
    }

    return cnt==len;
}

ll find_cost(ll len){
    ll val1 = cumi1[len];
    ll tot = 0;

    ll tp  = p;
    for(ll i = 1,j=len; i <= len; i++,j--){
        if(arr1[i] >= arr2[j]) tot += arr2[j];
        else{
            ll l = arr2[j]-arr1[i];
            tp-=l;
            tot+=arr1[i];
        }
    }

    return tot - tp;
}
int main(){

    scanf("%lld %lld %lld",&n,&m,&p);

    for(ll i = 1; i <= n; i++)
        scanf("%lld",arr1+i);

    for(ll i = 1; i <= m; i++)
        scanf("%lld",arr2+i);

    sort(arr1+1,arr1+n+1,comp);
    sort(arr2+1,arr2+m+1);

//    for(ll i = 1; i <= n; i++){
//        printf("%lld ",arr1[i]);
//    }
//    printf("\n");
//    for(ll i = 1; i <= n)
    for(ll i = 1; i <= n; i++)
        cumi1[i] = cumi1[i-1] + arr1[i];

    for(ll i = 1; i <= m; i++)
        cumi2[i] = cumi2[i-1] + arr2[i];

    ll lo = 0,hi=n;
    ll min_cost = 0;
    while(lo < hi){

        ll mid = (lo + hi + 1)/2;

        if(ask(mid)){
            lo = mid;
        }
        else{
            hi = mid-1;
        }
    }

    min_cost = find_cost(lo);
    printf("%lld %lld\n",lo,min_cost);
}


#include <bits/stdc++.h>
#define mx 100010
using namespace std;

typedef long long int ll;

vector <ll> a,b;
bool taken[mx];

int main(){
    //freopen("in.txt","r",stdin);
    ll n,m,p;

    scanf("%lld %lld %lld",&n,&m,&p);
    ll tp = p;
    ll psum = 0;
    for(ll i = 0; i < n; i++){
        ll temp;

        scanf("%lld",&temp);
        a.push_back(temp);
    }

    for(ll i = 0; i < m; i++){
        ll temp;

        scanf("%lld",&temp);
        b.push_back(temp);
    }

    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    ll cnt = 0;
    ll j = 0,i;

    for(i = 0; i < a.size(); i++){
        while(b[j] > a[i] && j < b.size())
            j++;
        if(j < b.size()){
            if(b[j] <= a[i]){
                taken[j] = true;

                psum+=b[j];
                cnt++;
                //printf("psum: %lld\n",psum);
                //printf("j: %lld i: %lld b[j]: %lld a[i]: %lld\n",j,i,b[j],a[i]);
                j++;
            }
        }
        else{
            break;
        }
    }

//    printf("%lld\n",psum);
//
//    for(int i = 0; i < a.size(); i++)
//        printf("%lld ",a[i]);
//    printf("\n");
//    for(int i = 0; i < b.size(); i++)
//        printf("%lld ",b[i]);
//    printf("\n");
    j = b.size()-1;
    for(; i < a.size(); i++){
        while(taken[j] == true && j >= 0)
            j--;
        //printf("j: %lld i: %lld b[j]: %lld psum: %lld\n",j,i,b[j],psum);
        if(j >= 0){
            if(b[j]-a[i] <= tp){
                tp-=(b[j]-a[i]);
                taken[j] = true;
                psum += a[i];
                cnt++;
                //printf("entered\n");
            }
            else
                break;
        }
        else{
            break;
        }
    }

    i = 0, j = b.size()-1;

    while(i < j){
        while(taken[j] == true && j >= 0)
            j--;
        while(taken[i] == false && i < b.size())
            i++;
        //printf("j: %lld i: %lld\n",j,i);
        if(j >= 0 && i < b.size()){
            //printf("%lld %lld\n\n",b[j],a[i]);
            psum -= (b[i]-b[j]);
            taken[j] = false;
            taken[i] = true;
            i++;
            j--;
        }
    }

    psum -= tp;
    psum = max(ll(0),psum);

    printf("%lld %lld",cnt,psum);

}


#include<bits/stdc++.h>

using namespace std;

#define int long long

signed main(){
	int n,m,a;
	cin >> n >> m >> a;
	int b[n];
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	int p[m];
	for(int i=0;i<m;i++){
		cin >> p[i];
	}
	sort(b,b+n);
	sort(p,p+m);
	int i=0,j=n-1,ind=0;
	if(b[n-1]+a<p[0]){
		cout << 0 << " " << 0 << endl;
		exit(0);
	}
	while(i<=j){
		int mid=(i+j)/2;
		if(b[mid]+a<p[0]){
			i=mid+1;
		}
		else{
			j=mid-1;
			ind=mid;
		}
	}
	//cout << "ind " << ind << endl;
	//int k=n-ind,cnt=0;
	for(int k=n-ind;k>=1;k--){
		int shr=a,per=0,i,j=0;
		for(i=n-k;i<n;i++,j++){
			//cout << "i " << i << " b " << b[i] << " p " << p[i] << " shr " << shr << endl;
			if(b[i]>=p[j]){
				per+=p[j];
			}
			else if(b[i]+shr>=p[j]){
				per+=b[i];
				shr-=(p[j]-b[i]);
			}
			else{
				break;
			}
		}
		//cout << "i " << i << endl;
		if(i==n){
			cout << k << " " << max(0ll,per-shr) << endl;
			exit(0);
		}
	}
}


#include<bits/stdc++.h>

using namespace std;

#define int long long

signed main(){
	int n,m,a;
	cin >> n >> m >> a;
	int b[n];
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	int p[m];
	for(int i=0;i<m;i++){
		cin >> p[i];
	}
	sort(b,b+n);
	sort(p,p+m);
	int i=0,j=n-1,ind=0;
	if(b[n-1]+a<p[0]){
		cout << 0 << " " << 0 << endl;
		exit(0);
	}
	while(i<=j){
		int mid=(i+j)/2;
		if(b[mid]+a<p[0]){
			i=mid+1;
		}
		else{
			j=mid-1;
			ind=mid;
		}
	}
	//cout << "ind " << ind << endl;
	//int k=n-ind,cnt=0;
	for(int k=n-ind;k>=1;k--){
		int shr=a,per=0,i,j=0;
		for(i=n-k;i<n;i++,j++){
			//cout << "i " << i << " b " << b[i] << " p " << p[i] << " shr " << shr << endl;
			if(b[i]>=p[j]){
				per+=p[j];
			}
			else if(b[i]+shr>=p[j]){
				per+=b[i];
				shr-=(p[j]-b[i]);
			}
			else{
				break;
			}
		}
		//cout << "i " << i << endl;
		if(i==n){
			cout << k << " " << per-shr << endl;
			exit(0);
		}
	}
}


#include<bits/stdc++.h>

using namespace std;

#define int long long

signed main(){
	int n,m,a;
	cin >> n >> m >> a;
	int b[n];
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	int p[m];
	for(int i=0;i<m;i++){
		cin >> p[i];
	}
	sort(b,b+n);
	sort(p,p+m);
	int i=0,j=n-1,ind=0;
	if(b[n-1]+a<p[0]){
		cout << 0 << " " << 0 << endl;
		exit(0);
	}
	while(i<=j){
		int mid=(i+j)/2;
		if(b[mid]+a<p[0]){
			i=mid+1;
		}
		else{
			j=mid-1;
			ind=mid;
		}
	}
	//cout << "ind " << ind << endl;
	//int k=n-ind,cnt=0;
	int l=1,r=n-ind,ans,usd;
	while(l<=r){
		int k=(l+r)/2;
		int shr=a,per=0,i,j=0;
		for(i=n-k;i<n;i++,j++){
			//cout << "i " << i << " b " << b[i] << " p " << p[i] << " shr " << shr << endl;
			if(b[i]>=p[j]){
				per+=p[j];
			}
			else if(b[i]+shr>=p[j]){
				per+=b[i];
				shr-=(p[j]-b[i]);
			}
			else{
				break;
			}
		}
		//cout << "i " << i << endl;
		if(i==n){
			ans=k;
			usd=max(0ll,per-shr);
			l=k+1;
		}
		else{
			r=k-1;
		}
	}
	cout << ans << " " << usd << endl;
}


#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;

int b[N], p[N];
ll prefp[N], prefb[N];
int r, s;
int n, m, a;
bool ck(int);
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m >> a;
    for(int i = 1; i <= n; ++i){
        cin >> b[i];
    }
    for(int i = 1; i <= m; ++i){
        cin >> p[i];
    }
    sort(p + 1, p + 1 + m);
    sort(b + 1, b + 1 + n);
    reverse(b + 1, b + 1 + n);
    for(int i = 1; i < N; ++i) {
        prefb[i] = prefb[i - 1] + b[i];
        prefp[i] = prefp[i - 1] + p[i];
    }
    int t = min(n, m);
    int lo = 0, hi = t;

    while(lo <= hi){
        int mid = (lo + hi) / 2;
        if(ck(mid)){
            lo = mid + 1;
        }else{
            hi = mid - 1;
        }
    }
    cout << r << ' ' << s;
}

bool ck(int x){
    if(prefp[x] > prefb[x] + a) return false;
    ll nd = 0;
    for(int i = 1; i <= x; ++i){
        nd += max(0, p[i] - b[x - i + 1]);
    }
    if(nd > a) return false;
    else{
        r = x;
        s = prefp[x] - a;
        return true;
    }
}


#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;

int b[N], p[N];
ll prefp[N], prefb[N];
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n, m, a; cin >> n >> m >> a;
    for(int i = 1; i <= n; ++i){
        cin >> b[i];
    }
    for(int i = 1; i <= m; ++i){
        cin >> p[i];
    }
    sort(p + 1, p + 1 + m);
    sort(b + 1, b + 1 + n);
    reverse(b + 1, b + 1 + n);
    for(int i = 1; i < N; ++i) {
        prefb[i] = prefb[i - 1] + b[i];
        prefp[i] = prefp[i - 1] + p[i];
    }
    int t = min(n, m);
    ll us = 0;
    while(t){
        ll need = prefp[t];
        ll hv = a + prefb[t];
        if(hv >= need){
            us = max(0LL, need - a);
            break;
        }
        --t;
    }
    cout << t << ' ' << us << '\n';
}


#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;

int b[N], p[N];
ll prefp[N], prefb[N];
int r;
ll s;
int n, m, a;
bool ck(int);
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m >> a;
    for(int i = 1; i <= n; ++i){
        cin >> b[i];
    }
    for(int i = 1; i <= m; ++i){
        cin >> p[i];
    }
    sort(p + 1, p + 1 + m);
    sort(b + 1, b + 1 + n);
    reverse(b + 1, b + 1 + n);
    for(int i = 1; i < N; ++i) {
        prefb[i] = prefb[i - 1] + b[i];
        prefp[i] = prefp[i - 1] + p[i];
    }
    int t = min(n, m);
    int lo = 0, hi = t;

    while(lo <= hi){
        int mid = (lo + hi) / 2;
        if(ck(mid)){
            lo = mid + 1;
        }else{
            hi = mid - 1;
        }
    }
    cout << r << ' ' << s;
}

bool ck(int x){
    if(prefp[x] > prefb[x] + a) return false;
    ll nd = 0;
    for(int i = 1; i <= x; ++i){
        nd += max(0, p[i] - b[x - i + 1]);
    }
    if(nd > a) return false;
    else{
        r = x;
        s = max(0LL, prefp[x] - a);
        return true;
    }
}