标签:des style blog http java color
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4375 Accepted Submission(s): 1297
1 #include <iostream> 2 #include <stdio.h> 3 #include <algorithm> 4 #include <string.h> 5 #include <set> 6 using namespace std; 7 #define ll long long 8 ll a[5][300],s1[90000],s2[90000],s3[90000],sn1,sn2,sn3; 9 int main() 10 { 11 int n,t,i,j,k; 12 cin>>t; 13 while(t--) 14 { 15 cin>>n; 16 for(i=0; i<5; i++) 17 for(j=0; j<n; j++) 18 scanf("%I64d",&a[i][j]); 19 sn1=sn2=sn3=0; 20 for(i=0; i<n; i++) 21 for(j=0; j<n; j++) 22 s1[sn1++]=a[0][i]+a[1][j]; 23 for(i=0; i<n; i++) 24 for(j=0; j<n; j++) 25 s2[sn2++]=a[2][i]+a[3][j]; 26 for(i=0; i<n; i++) 27 s3[sn3++]=-a[4][i]; 28 sort(s1,s1+sn1); 29 sort(s2,s2+sn2); 30 sort(s3,s3+sn3); 31 int ok=0; 32 for(i=0;!ok&&i<sn3;i++) 33 { 34 j=0,k=sn2-1; 35 while(j<sn1&&k>=0) 36 { 37 if(s1[j]+s2[k]==s3[i]) 38 { 39 ok=1; 40 break; 41 } 42 while(j<sn1&&k>=0&&s1[j]+s2[k]>s3[i])k--; 43 while(j<sn1&&k>=0&&s1[j]+s2[k]<s3[i])j++; 44 } 45 } 46 if(ok)printf("Yes\n"); 47 else printf("No\n"); 48 } 49 }
hdu 4334 Trouble,布布扣,bubuko.com
标签:des style blog http java color
原文地址:http://www.cnblogs.com/ERKE/p/3832288.html