Posted on 2008-09-19 12:35
Hero 阅读(113)
评论(0) 编辑 收藏 引用 所属分类:
代码如诗--ACM
1 //2366 Accepted 5900K 94MS C++ 954B PKU
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6
7 const int size = 72768 ;
8 int data1[size*10] ;
9 int data2[size*10] ;
10
11 int inn, inm ;
12
13 void input()
14 {
15 memset( data1, 0, sizeof(data1) ) ;
16 memset( data2, 0, sizeof(data2) ) ;
17
18 int ina ;
19 for( int i=1; i<=inn; i++ )
20 {
21 scanf( "%d", &ina ) ; ina += size ;
22 data1[ina] = 1 ;
23 }
24
25 scanf( "%d", &inm ) ;
26 for( int i=1; i<=inm; i++ )
27 {
28 if( scanf( "%d", &ina ) != EOF )
29 {
30 ina += size ;
31 data2[ina] = 1 ;
32 }
33 }
34 }
35
36 void process()
37 {
38 bool YES = false ;
39 int maxi = size * 2 ; int tofind = 10000 + size*2 ;
40 for( int i=0; i<maxi; i++ ) if( data1[i] )
41 {
42 if( (tofind-i)<maxi && (tofind-i)>=0 && data2[tofind-i] )
43 {
44 YES = true ; break ;
45 }
46 }
47
48 if( YES )
49 printf( "YES\n" ) ;
50 else
51 printf( "NO\n" ) ;
52 }
53
54 int main()
55 {
56 while( scanf( "%d", &inn ) != EOF )
57 {
58 input() ;
59
60 process() ;
61
62 //output() ;
63 }
64
65 return 0 ;
66 }