| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
大家帮忙看一下2366吧,很弱的一个题,我在URAL上过了,可是在这里总是WA! 没用HASH做,用的2分!#include <iostream>
#include <cmath>
#include <string>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define MAXN 70000
long a[MAXN],b[MAXN];
int na;
bool find(long x)
{
int start=0,end=na-1;
while(start<=end)
{
int mid=(start+end)/2;
if(x>a[mid]) start=mid+1;
else if(x<a[mid]) end=mid-1;
else return true;
}
return false;
}
int main()
{
register int i;
int nb;
scanf("%d",&na);
for(i=0;i<na;i++)
scanf("%d",a+i);
scanf("%d",&nb);
for(i=0;i<nb;i++)
scanf("%d",b+i);
for(i=0;i<nb;i++)
if(find(10000-b[i]))
{
printf("YES\n");
goto elf;
}
printf("NO\n");
elf:;
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator