Suppose you are given an array a[]={2,3,1,4,6,7,10}
now for successfully transferring the ball,from ith city to jth city,a[i] >
max(a[i..j-1]).
A naive approach would be to calculate all possible max[i][j] that is max
for each interval and then answer the query in 0(1) time.Another approach
would b
u construct a tree nlogn , every node answers a query.. (or u get ans with a
recursion) in log(n) , so when u r doing a lot of query RMQ proves to be
very fast
On Fri, Jun 10, 2011 at 6:28 PM, nicks wrote:
> ya i saw that in the comments on spoj someone suggested to use RMQcan
> you explain
ya i saw that in the comments on spoj someone suggested to use RMQcan
you explain a bit moe how to implement RMQ and how it is helping in reducing
the time !!
On Fri, Jun 10, 2011 at 5:53 AM, saurabh singh wrote:
> Use Range Maximum Query.
>
>
> On Fri, Jun 10, 2011 at 4:15 PM, kartik sa
Use Range Maximum Query.
On Fri, Jun 10, 2011 at 4:15 PM, kartik sachan wrote:
> how should we get TLE loop total running less than 10^6??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algo
how should we get TLE loop total running less than 10^6??
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@go
i agree with the logici also implemented it...and getting TLE...there
must exist some better method :(
On Fri, Jun 10, 2011 at 2:18 AM, kartik sachan wrote:
> what i understand from the problem was that.
> n no of higests are given
> and a and b and city no i.e from city a a ball
what i understand from the problem was that.
n no of higests are given
and a and b and city no i.e from city a a ball is thrown to city no b
so i have done
from array a[] i.e hieght { n...no of times}
find all the element between b[i].city A and
c[i]city
@Karthik : Can you please the logic ??. Would be nice ..
On Fri, Jun 10, 2011 at 12:42 PM, kartik sachan wrote:
> http://www.spoj.pl/problems/THRBL/
>
> my code is
> i am getting TLE
>
> # include
> # include
> using namespace std;
> //int search(long long int [],long long )
> int main()
> {
> wh
http://www.spoj.pl/problems/THRBL/
my code is
i am getting TLE
# include
# include
using namespace std;
//int search(long long int [],long long )
int main()
{
while(1)
{
int n,m;
int count=0;
long long int a[50010]={0};
int b[50010],c[50010];
if((scanf("%d%d",&n,&m))==EOF)
break;
int i;
for(i=0;