tag:blogger.com,1999:blog-7342229757832365594.post5396283312391734373..comments2023-04-28T04:10:43.605-07:00Comments on HINTS AND SOLUTION TO SPOJ QUESTIONS: ARRAYSUBSushanthttp://www.blogger.com/profile/14186565366407945495noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-7342229757832365594.post-31305033854126031572016-01-12T09:31:31.502-08:002016-01-12T09:31:31.502-08:00Sorry for the late reply.
Even I tried your code a...Sorry for the late reply.<br />Even I tried your code and it gives TLE. My algorithm has a time complexity of O(n*n) still it passes in 0.69s and your algo having a time complexity of of O(n) gives TLE.<br />i think there must be some loop hole. Check for some trivial case, there might be an infinite loop running.Sushanthttps://www.blogger.com/profile/14186565366407945495noreply@blogger.comtag:blogger.com,1999:blog-7342229757832365594.post-31236056449127039902015-12-28T07:42:46.705-08:002015-12-28T07:42:46.705-08:00#include
#include
#include
#include
#include
#incl...#include<br />#include<br />#include<br />#include<br />#include<br />#include <br />#include<br />#include<br />using namespace std;<br />int main()<br />{int t;<br /> cin>>t;<br /> int a[t];<br /> for(int i=1;i<=t;i++)<br /> {<br /> cin>>a[i];<br /> }<br /> int k;<br /> cin>>k;<br /> int u=k;<br /> int m=-1,v=1;<br />for(int i=v;i<=k && i<=t;i++)<br /> {<br /> if(a[i]>m)<br /> m=a[i];<br /> <br /> if((i-(v-1))%u==0)<br /> {<br /> cout<<m<<" ";<br /> k+=1;<br /> <br /> i=v;<br /> v++;<br /> m=0;<br /> <br /> }<br /> <br /> <br /> <br /> <br />}<br /> <br /> return 0;<br />}<br />why it shows time limit exceeded!!!Anonymousnoreply@blogger.com