We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Solving the problem itself was easy, but testing result said:
Time limit exceeded
Your code did not execute within the time limits. Please optimize your code. For more information on execution time limits, refer to the environment page
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>usingnamespacestd;intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */intn,num,numOfQ,q,targetIndex;cin>>n;vector<int>ints;for(inti=0;i<n;i++){cin>>num;ints.push_back(num);}cin>>numOfQ;for(inti=0;i<numOfQ;i++){cin>>q;for(intj=0;j<n;j++){if(q==ints[j]){targetIndex=j;cout<<"Yes "<<targetIndex+1<<endl;break;}elseif(ints[j]>q){targetIndex=j;cout<<"No "<<targetIndex+1<<endl;break;}}}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Lower Bound-STL
You are viewing a single comment's thread. Return to all comments →
Solving the problem itself was easy, but testing result said: