View Code of Problem 3815

#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<ctime>
using namespace std;
const int maxn =  200100;

int a[maxn],b[maxn];

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

int main()
{
	FILE *p;
	//p = fopen("item.txt","r");
    int T;
    int n,m,k;
   // fscanf(p,"%d",&T);
	scanf("%d",&T);
    while(T--)
    {
        fscanf(p,"%d %d %d",&n,&m,&k);
        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,cmp);
        int ans = 0,pos = 0;
        for(int i = 0;i < m;i++)
        {
            while(pos < n)
            {
                if(a[pos] + b[i] >= k)
                {
                    ans ++;
                    pos ++;
                    break;
                }
                pos ++;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 3815