# HNU11376:Golf Bot

 Problem description Input The first line has one integer: N, the number of different distances the Golf Bot can shoot. Each of the following N lines has one integer, ki, the distance marked in position i of the knob. Next line has one integer: M, the number of holes in this course. Each of the following M lines has one integer, dj , the distance from Golf Bot to hole j. 1<=N,M<=200 000 1<=ki,dj<=200 000 Output You should output a single integer, the number of holes Golf Bot will be able to complete. Golf Bot cannot shoot over a hole on purpose and then shoot backwards. Sample Input 3 1 3 5 6 2 4 5 7 8 9 Sample Output 4 Problem Source HNU Contest

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;

#define ls 2*i
#define rs 2*i+1
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define W(a) while(a)
#define gcd(a,b) __gcd(a,b)
#define LL long long
#define N 200005
#define INF 0x3f3f3f3f
#define EXP 1e-8
#define rank rank1
const int mod = 1000000007;

int hsh[N*2];
int a[N],b[N];

int main()
{
int n,m,i,j,k;
while(~scanf("%d",&n))
{
MEM(hsh,0);
for(i = 0; i<n; i++)
{
scanf("%d",&a[i]);
hsh[a[i]] = 1;
}
sort(a,a+n);
for(i = 0; i<n; i++)
{
for(j = i; j<n; j++)
{
hsh[a[i]+a[j]] = 1;
}
}
int ans = 0;
scanf("%d",&m);
for(i = 0; i<m; i++)
{
scanf("%d",&b[i]);
if(hsh[b[i]])
ans++;
}
printf("%d\n",ans);
}

return 0;
}


• 点赞
• 评论
• 分享
x

海报分享

扫一扫，分享海报

• 收藏
• 手机看

分享到微信朋友圈

x

扫一扫，手机阅读

• 打赏

打赏

键盘上的舞者

你的鼓励将是我创作的最大动力

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文
08-13 9453

08-23 3949
09-14 5312
08-25
03-23
04-15 4792