Source Code
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <stdlib.h> 
#include <time.h>
#include <stack>
#include <map>
#include <math.h>
#include <cmath>
#include <string.h>
using namespace std;
typedef vector<int> vi ;
typedef long long ll;
#define all(x) (x).begin() , (x).end()
#define pb push_back 
const int N = 2e5+1, M=1e6+1 , MX = 1e6+1;
const ll MXL=1e18 , MOD = 1e9 + 7 ; 
int a[N], b[N], curr[N];
ll ans=-MX , sum ;
int main(){
// 	freopen("input.txt", "r", stdin);
	int n, m, q;
	scanf("%d%d" , &n , &m );
	for(int i=0 ; i<n ; i++)
		scanf("%d" , a+i );
	sort(a, a+n);
	reverse(a, a+n );
	for(int i=0 ; i<m ; i++ )
		scanf("%d" , b+i );
	scanf("%d" , &q );
	while ( q-- ){
		int x, cnt=0;
		scanf("%d" , &x );
		for(int i=0 ; i<n ; i++ )
			curr[i] = x-a[i];
		for(int i=0 ; i<n ; i++ )
			if( curr[i] <= m )
				cnt++;
		printf("%d " , cnt);
	}
  return 0 ; 
}
Copy
Votes Rand()
GNU G++17
0 ms
444 KB
Wrong Answer