|
|
вернуться в форумcould anyone tell me how to solve MLE? //my program's as follows #include <iostream> #include <algorithm> using namespace std; int main() { long n,m,i,j,*p,*q,count=0; bool found; cin>>n; p=(long *)malloc(n*4); for(i=0;i<n;i++) cin>>*(p+i); cin>>m; q=(long *)malloc(m*4); for(j=0;j<m;j++) { cin>>*(q+j); found=binary_search(p,(p+n),*(q+j)); if(found) count++; } cout<<count<<endl; return 0; } Re: could anyone tell me how to solve MLE? Maybe, binary_search is recursive? Re: could anyone tell me how to solve MLE? #include <iostream> #include <algorithm> #include <vector> using namespace std; int n; vector<int> a(0); int m; void init_solve() { cin>>n; int c; for(int i=0;i<n;i++) { cin>>c; a.push_back(c); }
cin>>m; int br=0; for(int i=0;i<m;i++) { cin>>c; if(binary_search(a.begin(),a.end(),c)) br++; } cout<<br<<'\n';
} int main() { init_solve(); return 0; } Re: could anyone tell me how to solve MLE? hey,friend,it's really kool,the <vector>, isn't it?:) thanks for teaching me... |
|
|