|
|
вернуться в форумPlease help me! I do not know how to charge the time. Послано hit 20 ноя 2015 20:25 #include<stdio.h> #include<stdlib.h> int main() { int m,n,a[50000],b[50000],i,j,p,c; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } scanf("%d",&m); for(i=0;i<m;i++) { scanf("%d",&b[i]); } for(j=0;j<n;j++) { for(p=0;p<m;p++) { c=a[j]+b[p]; if(c==10000) { printf("YES"); exit(0); } } } printf("NO"); return 0; } Re: Please help me! I do not know how to charge the time. Послано Hexo 20 ноя 2015 23:45 in my mind, two loops is not required. Try to use binary search in sorted array. steps: 1.Take from first array the number; 2.1000-[this number] 3.find 1000-[this number] in second array(use binary search) This way, you have only one loop. Edited by author 20.11.2015 23:45 Edited by author 20.11.2015 23:45 No subject Послано Hunter 27 апр 2016 14:58 Thanks a lot!!! |
|
|